Moderator: Board moderators
deleted

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
char word[21];
double sum=0;
int i,y,factor;
while(gets(word) != NULL)
{
factor=0;
for(i=0;i<20;i++)
{
if(word[i]>='a' && word[i]<='z')
sum = sum +(word[i]-96);
else if(word[i]>='A' && word[i]<='Z')
sum = sum +(word[i]-38);
}
for (y = 2; y <= sqrt(sum); y++)
{
if ( fmod(sum,y)==0 )
factor++;
}
if (factor == 0)
printf("It is a prime word.\n");
else
printf("It is not a prime word.\n");
}
return 0;
}
a
b
c
d
e
A
B
C
D
E
It is a prime word.
It is a prime word.
It is a prime word.
It is not a prime word.
It is a prime word.
It is not a prime word.
It is not a prime word.
It is a prime word.
It is not a prime word.
It is a prime word.
/* Prime Words */
REMOVED, got AC
if (1)
printf("\n");if (c!=EOF)
printf("\n");an EMPY string should NOT to print ANYTHING
1 is prime
[/quote]print a \n after ALL cases
removed after being AC.
sazzadcsedu wrote:whats wrong with this code!!!!!!!!!
i got WA.
- Code: Select all
memset(prime,0,sizeof(prime));
for(i=2;i<=20;i++)
{
for(j=2;j<=60;j++)
{
prime[i*j]=1;
}
}
Users browsing this forum: No registered users and 0 guests