Friday, August 19

PROBLEM: Make a program that will receive a string input and print the letters that is prime repeated.


#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int c=0,d,x,y,z,L,e=0;
    char str[100];
    cout<<"Enter String: ";
    gets(str);
    L=strlen(str);
    cout<<"\n\n\tResult: ";
    for(x=0;x<L;x++){
                     for(y=0;y<L;y++){
                                      if(x==' '){continue;}
                                      if(y==x){continue;}
                                      if(str[x]==str[y]){c++;}
                                      }
                                      d=c+1;
                                      for(z=c;z>1;z--){
                                                         if(d%z==0){e++;}
                                                         }
                                                       
                   
                     if(e==0){cout<<str[x];}
                     c=0;
                     d=0;
                     e=0;
                                                       }
                                                       cout<<"\n\n\n";
                                                     
                                                     
    system("PAUSE");
    return EXIT_SUCCESS;
}


/*Program Preview*/


No comments:

Post a Comment