Saleh127

UVA 739

Jun 21st, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int i,j,k,l;
  6. char x[100];
  7. for(i=1;i<10;i++)
  8. {
  9. cout<<" ";
  10. }
  11. cout<<"NAME";
  12. for(i=i+4;i<35;i++)
  13. {
  14. cout<<" ";
  15. }
  16. cout<<"SOUNDEX CODE\n";
  17. while(scanf("%s",x)!=EOF)
  18. {
  19. l=strlen(x);
  20. for(i=1;i<10;i++)
  21. {
  22. cout<<" ";
  23. }
  24. printf("%s",x);
  25. for(i=i+l;i<35;i++)
  26. {
  27. cout<<" ";
  28. }
  29. cout<<x[0];
  30. int a[50];
  31. for(j=0;j<25;j++)
  32. {
  33. a[j]=0;
  34. }
  35. k=0;
  36. for(j=1;j<l;j++)
  37. {
  38. if(x[j]=='A' || x[j]=='E' || x[j]=='I' || x[j]=='O' || x[j]=='U' || x[j]=='Y' || x[j]=='W' || x[j]=='H')
  39. {
  40. continue;
  41. }
  42. if(x[j]=='B' || x[j]=='P' || x[j]=='F' || x[j]=='V')
  43. {
  44. if(x[j-1]=='B' || x[j-1]=='P' || x[j-1]=='F' || x[j-1]=='V')
  45. {
  46. continue;
  47. }
  48. a[k]=1;
  49. k++;
  50. continue;
  51. }
  52. if(x[j]=='C' || x[j]=='S' || x[j]=='K' || x[j]=='G' || x[j]=='J' || x[j]=='Q' || x[j]=='X' || x[j]=='Z')
  53. {
  54. if(x[j-1]=='C' || x[j-1]=='S' || x[j-1]=='K' || x[j-1]=='G' || x[j-1]=='J' || x[j-1]=='Q' || x[j-1]=='X' || x[j-1]=='Z')
  55. {
  56. continue;
  57. }
  58. a[k]=2;
  59. k++;
  60. continue;
  61. }
  62. if(x[j]=='D' || x[j]=='T')
  63. {
  64. if(x[j-1]=='D' || x[j-1]=='T')
  65. {
  66. continue;
  67. }
  68. a[k]=3;
  69. k++;
  70. continue;
  71. }
  72. if(x[j]=='L')
  73. {
  74. if(x[j-1]=='L')
  75. {
  76. continue;
  77. }
  78. a[k]=4;
  79. k++;
  80. continue;
  81. }
  82. if(x[j]=='M' || x[j]=='N')
  83. {
  84. if(x[j-1]=='M' || x[j-1]=='N')
  85. {
  86. continue;
  87. }
  88. a[k]=5;
  89. k++;
  90. continue;
  91. }
  92. if(x[j]=='R')
  93. {
  94. if(x[j-1]=='R')
  95. {
  96. continue;
  97. }
  98. a[k]=6;
  99. k++;
  100. continue;
  101. }
  102. }
  103. cout<<a[0]<<a[1]<<a[2]<<endl;
  104. }
  105. for(i=1;i<20;i++)
  106. {
  107. cout<<" ";
  108. }
  109. cout<<"END OF OUTPUT\n";
  110. return 0;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment