比赛 20160707 评测结果 WWWWWWWWWW
题目名称 单词缩写 最终得分 0
用户昵称 @@@ 运行时间 0.030 s
代码语言 C++ 内存使用 0.32 MiB
提交时间 2016-07-07 16:29:25
显示代码纯文本
  1. #include <fstream>
  2. #include <string>
  3. #include <cstdio>
  4. using namespace std;
  5. ifstream cin("abbreviation.in");
  6. ofstream cout("abbreviation.out");
  7. int n,al;
  8. string a,word="";
  9. string ans;
  10. string z(string x)
  11. {
  12. for(int i=1;i<=al;i++)
  13. {
  14. if(x[i]>='a'&&x[i]<='z')
  15. x[i]=char(x[i]-'a'+'A');
  16. }
  17. return x;
  18. }
  19. int getl(int i)
  20. {
  21. int yi=i,k=0;
  22. word="";
  23. for(;i>=0&&a[i]!=' ';i--)
  24. {
  25. word+=a[i];
  26. k++;
  27. }
  28. if(k>3)
  29. {
  30. cout<<word[k-1];
  31. return 0;
  32. }
  33. if(k>=3)
  34. if(word!="DNA"&&word!="ROF"&&word!="EHT")
  35. cout<<word[k-1];
  36. return 0;
  37. }
  38. int main()
  39. {
  40. int i,j;
  41. cin>>n;
  42. getline(cin,a);
  43. for(j=1;j<=n;j++)
  44. {
  45. getline(cin,a);
  46. //ans="";
  47. al=a.length()-1;
  48. i=0;
  49. a=z(a);
  50. //cout<<a;
  51. while(i<=al)
  52. {
  53. if(a[i]==' '||a[i]=='/n')
  54. getl(i-1);
  55. i++;
  56. }
  57. getl(al);
  58. cout<<endl;
  59. }
  60. cin.close();
  61. cout.close();
  62. return 0;
  63. }