535A - Tavas and Nafas (535Tavas and Nafas )

  1. 535A - Tavas and Nafas
  2. A. Tavas and Nafas
     Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.
    His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no choice but to send this number using words.
    He ate coffee mix without water again, so right now he's really messed up and can't think.
    Your task is to help him by telling him what to type.
    Input
    The first and only line of input contains an integer s (0 ≤ s ≤ 99), Tavas's score.
    Output
    In the first and only line of output, print a single string consisting only from English lowercase letters and hyphens ('-'). Do not use spaces.
    Examples
    input
    Copy
    6
    output
    Copy
    six
    input
    Copy
    99
    output
    Copy
    ninety-nine
    input
    Copy
    20
    output
    Copy
    twenty
    Note
    You can find all you need to know about English numerals in http://en.wikipedia.org/wiki/English_numerals .



  3. ///bismillah
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6. int main(){
  7.  
  8. vector<string> v ={"zero","one","two",
  9. "three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fiveteen","sixteen","seventeen","eighteen","nineteen","twenty"};
  10. string s;
  11. cin>>s;int d=s.length();
  12. if(s.length()==1){
  13. int x=s[0]-48;
  14. cout <<v[x];
  15. }
  16. if(d==2 and s=="10"){ cout<<"ten"; }
  17. if(d==2 and s=="11"){ cout<<"eleven"; }
  18. if(d==2 and s=="12"){ cout<<"twelve"; }
  19. if(d==2 and s=="13"){ cout<<"thirteen"; }
  20. if(d==2 and s=="14"){ cout<<"fourteen"; }
  21. if(d==2 and s=="15"){ cout<<"fifteen"; }
  22. if(d==2 and s=="16"){ cout<<"sixteen"; }
  23. if(d==2 and s=="17"){ cout<<"seventeen"; }
  24. if(d==2 and s=="18"){ cout<<"eighteen"; }
  25. if(d==2 and s=="19"){ cout<<"nineteen"; }
  26.  
  27.  
  28. if(d==2 and s[0]=='2'){ cout <<"twenty";
  29. int x=s[1]-48;
  30. if(x!=0) cout<<"-"<<v[x];}
  31.  
  32. if(d==2 and s[0]=='3'){ cout <<"thirty";
  33. int x=s[1]-48;
  34. if(x!=0) cout<<"-"<<v[x];}
  35.  
  36. if(d==2 and s[0]=='4'){ cout <<"forty";
  37. int x=s[1]-48;
  38. if(x!=0) cout<<"-"<<v[x];}
  39.  
  40. if(d==2 and s[0]=='5'){ cout <<"fifty";
  41. int x=s[1]-48;
  42. if(x!=0) cout<<"-"<<v[x];}
  43.  
  44. if(d==2 and s[0]=='6'){ cout <<"sixty";
  45. int x=s[1]-48;
  46. if(x!=0) cout<<"-"<<v[x];}
  47.  
  48. if(d==2 and s[0]=='7'){ cout <<"seventy";
  49. int x=s[1]-48;
  50. if(x!=0) cout<<"-"<<v[x];}
  51.  
  52. if(d==2 and s[0]=='8'){ cout <<"eighty";
  53. int x=s[1]-48;
  54. if(x!=0) cout<<"-"<<v[x];}
  55.  
  56. if(d==2 and s[0]=='9'){ cout <<"ninety";
  57. int x=s[1]-48;
  58. if(x!=0) cout<<"-"<<v[x];}
  59.  
  60.  
  61.  
  62. }

Comments

Popular posts from this blog

Codeforce Problem 1703A. YES or YES?

Aptitude test assistant programmer 2018

1041A. Heist solution