fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. int T,i;
  5. char word[1000];
  6. scanf("%d",&T);
  7. char *str[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
  8. int arr[10]={0,1,2,3,4,5,6,7,8,9};
  9. while(T-->0) {
  10. scanf("%s",word);
  11. int minpos=0;
  12. int count=0;
  13. for(int i=0;i<=9;i++) {
  14. count=0;
  15. if(strlen(str[i])==strlen(word))
  16. {
  17. for(int j=0;j<strlen(word);j++)
  18. {
  19. if(word[j]!=str[i][j])
  20. {
  21. count++;
  22. }
  23. if(count>1)
  24. {
  25. count=0;
  26. break;
  27. }
  28. }
  29. if(count==1)
  30. {
  31. minpos=i;
  32. break;
  33. }
  34. }
  35. }
  36. cout<<arr[minpos]<<endl;
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0s 3464KB
stdin
3
owe
seren
rix
stdout
1
7
6