Advertisement
erfanul007

UVa 739

Dec 9th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char str[50];
  8. int i,j,k;
  9. for(i=1;i<10;i++){
  10. cout<<" ";
  11. }
  12. cout<<"NAME";
  13. for(i=i+4;i<35;i++){
  14. cout<<" ";
  15. }
  16. cout<<"SOUNDEX CODE"<<endl;
  17. while(scanf("%s",str)!=EOF){
  18. int ln=strlen(str);
  19. for(i=1;i<10;i++)
  20. cout<<" ";
  21. printf("%s",str);
  22. for(i=i+ln;i<35;i++)
  23. cout<<" ";
  24. cout<<str[0];
  25. int a[30];
  26. for(j=0;j<25;j++)
  27. a[j]=0;
  28. k=0;
  29. for(j=1;j<ln;j++){
  30. 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')
  31. continue;
  32. if(str[j]=='B' || str[j]=='P' || str[j]=='F' || str[j]=='V'){
  33. if(str[j-1]=='B' || str[j-1]=='P' || str[j-1]=='F' || str[j-1]=='V')
  34. continue;
  35. a[k]=1;
  36. k++;
  37. continue;
  38. }
  39. 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'){
  40. 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')
  41. continue;
  42. a[k]=2;
  43. k++;
  44. continue;
  45. }
  46. if(str[j]=='D' || str[j]=='T'){
  47. if(str[j-1]=='D' || str[j-1]=='T')
  48. continue;
  49. a[k]=3;
  50. k++;
  51. continue;
  52. }
  53. if(str[j]=='L'){
  54. if(str[j-1]=='L')
  55. continue;
  56. a[k]=4;
  57. k++;
  58. continue;
  59. }
  60. if(str[j]=='M' || str[j]=='N'){
  61. if(str[j-1]=='M' || str[j-1]=='N')
  62. continue;
  63. a[k]=5;
  64. k++;
  65. continue;
  66. }
  67. if(str[j]=='R'){
  68. if(str[j-1]=='R')
  69. continue;
  70. a[k]=6;
  71. k++;
  72. continue;
  73. }
  74. }
  75. cout<<a[0]<<a[1]<<a[2]<<endl;
  76. }
  77. for(i=1;i<20;i++){
  78. cout<<" ";
  79. }
  80. cout<<"END OF OUTPUT"<<endl;
  81. return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement