(总算是5题都做完了- -)
暂时做了4题,先放一下有时间做最后一题(当然如果我真的能做出的话。。。)(看了大神的代码总算是理解了E题,做完发现也没那么难,果然想出一个思路的过程对于我这种弱渣来说还是太强求了啊。。。)
A题:
英文单词别拼错就没什么问题吧
#include <cstdio> #include <cstring> using namespace std; char str[10][10] = {"" , "" , "twenty" , "thirty" , "forty" , "fifty" , "sixty" , "seventy" ,"eighty" , "ninety"}; char single[10][10] = {"zero" , "one","two","three","four","five","six","seven","eight","nine"}; char dou[10][10] = {"ten" ,"eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"}; int main() { int x; while(~scanf("%d" , &x)){ if(x<10){ printf("%s\n" , single[x]); } else if(x<20){ printf("%s\n" , dou[x%10]); } else{ int tmp = x%10; printf("%s" , str[x/10]); if(tmp){ printf("-%s" , single[tmp]); } printf("\n"); } } return 0; }