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()
- {
- freopen("input.txt","r",stdin);
- 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]==str[j-1])
- continue;
- if(str[j]=='B' || str[j]=='P' || str[j]=='F' || str[j]=='V'){
- 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'){
- a[k]=2;
- k++;
- continue;
- }
- if(str[j]=='D' || str[j]=='T'){
- a[k]=3;
- k++;
- continue;
- }
- if(str[j]=='L'){
- a[k]=4;
- k++;
- continue;
- }
- if(str[j]=='M' || str[j]=='N'){
- a[k]=5;
- k++;
- continue;
- }
- if(str[j]=='R'){
- 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