rev='made'/> name='keywords'/> name='author'/> ANURANAN: UVa Solution 10924:Prime Words

Welcome Note

Hi,
I'm Anisuzzaman Babla . I am a full stack Android Application Developer. I am working with Android for more than two years. I have completed my graduation from IIT, Jahangirnagar University. I have developed a series of commercially successful apps on Android. Moreover, 10+ of my Apps are live at Google play store. .
Thank You

UVa Solution 10924:Prime Words

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define s 2000
using namespace std;
int prime[s];
void primeGenerate()
{
    int i,j,m;
    m=sqrt(s);
    memset (prime,1,sizeof(prime));    //it set 1 in all array element.
    prime[0]=0;
    prime[1]=1;
    for(i=2;i<m;i++)
        if(prime[i])
            for(j=i+i;j<s;j+=i)
prime[j]=0;
}
int main()
{
    //freopen("in.txt","r",stdin);
    primeGenerate();
    char str[30];
    int i,num;
    while(gets(str))
    {
        num=0;
        for(i=0;str[i];i++)
        {
            if(str[i]>='a' && str[i]<='z')
                num=num+str[i]-'a'+1;
            else
                num=num+str[i]-'A'+27;
        }
        if(prime[num])
            cout<<"It is a prime word.\n";
        else
            cout<<"It is not a prime word.\n";
    }
    return 0;
}