Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<cmath>
- using namespace std;
- int main()
- {
- char str[50];
- int i,j,k;
- for(i=1;i<10;i++){
- cout<<" ";
- }
- cout<<"NAME";
- for(i=i+4;i<35;i++){
- cout<<" ";
- }
- cout<<"SOUNDEX CODE"<<endl;
- while(scanf("%s",str)!=EOF){
- int ln=strlen(str);
- for(i=1;i<10;i++)
- cout<<" ";
- printf("%s",str);
- for(i=i+ln;i<35;i++)
- cout<<" ";
- cout<<str[0];
- int a[30];
- for(j=0;j<25;j++)
- a[j]=0;
- k=0;
- for(j=1;j<ln;j++){
- if(str[j]=='A' || str[j]=='E' || str[j]=='I' || str[j]=='O' || str[j]=='U' || str[j]=='Y' || str[j]=='W' || str[j]=='H')
- continue;
- if(str[j]=='B' || str[j]=='P' || str[j]=='F' || str[j]=='V'){
- if(str[j-1]=='B' || str[j-1]=='P' || str[j-1]=='F' || str[j-1]=='V')
- continue;
- a[k]=1;
- k++;
- continue;
- }
- if(str[j]=='C' || str[j]=='S' || str[j]=='K' || str[j]=='G' || str[j]=='J' || str[j]=='Q' || str[j]=='X' || str[j]=='Z'){
- if(str[j-1]=='C' || str[j-1]=='S' || str[j-1]=='K' || str[j-1]=='G' || str[j-1]=='J' || str[j-1]=='Q' || str[j-1]=='X' || str[j-1]=='Z')
- continue;
- a[k]=2;
- k++;
- continue;
- }
- if(str[j]=='D' || str[j]=='T'){
- if(str[j-1]=='D' || str[j-1]=='T')
- continue;
- a[k]=3;
- k++;
- continue;
- }
- if(str[j]=='L'){
- if(str[j-1]=='L')
- continue;
- a[k]=4;
- k++;
- continue;
- }
- if(str[j]=='M' || str[j]=='N'){
- if(str[j-1]=='M' || str[j-1]=='N')
- continue;
- a[k]=5;
- k++;
- continue;
- }
- if(str[j]=='R'){
- if(str[j-1]=='R')
- continue;
- a[k]=6;
- k++;
- continue;
- }
- }
- cout<<a[0]<<a[1]<<a[2]<<endl;
- }
- for(i=1;i<20;i++){
- cout<<" ";
- }
- cout<<"END OF OUTPUT"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement