朱色虫居
Pages
Home
Featured Posts
2006/09/30
10924-Prime Words
/*
"Prime Words"
Level:1.0(我自訂的)
Date:2006/9/29
*/
#include
#include
#define N 1041
#define DATA 21
main(){
int i=0,j=0,sum=0;
bool num[N]={true};
char s[DATA]={};
for(i=2;i*i<=N;i++) for(j=2*i;j<=N;j++) if(j%i == 0) num[j]= true; while(gets(s)){ i=sum=0; while(s[i]!= '\0'){ if(islower(s[i])) sum += (s[i]-96); else sum += (s[i]-38); i++; } if(!num[sum]) printf("It is a prime word.\n"); else printf("It is not a prime word.\n"); } }
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment