比赛 |
20160707 |
评测结果 |
WWWWWWWWWW |
题目名称 |
单词缩写 |
最终得分 |
0 |
用户昵称 |
@@@ |
运行时间 |
0.030 s |
代码语言 |
C++ |
内存使用 |
0.32 MiB |
提交时间 |
2016-07-07 16:29:25 |
显示代码纯文本
- #include <fstream>
- #include <string>
- #include <cstdio>
- using namespace std;
- ifstream cin("abbreviation.in");
- ofstream cout("abbreviation.out");
- int n,al;
- string a,word="";
- string ans;
- string z(string x)
- {
- for(int i=1;i<=al;i++)
- {
- if(x[i]>='a'&&x[i]<='z')
- x[i]=char(x[i]-'a'+'A');
-
- }
- return x;
- }
- int getl(int i)
- {
- int yi=i,k=0;
- word="";
- for(;i>=0&&a[i]!=' ';i--)
- {
- word+=a[i];
- k++;
- }
- if(k>3)
- {
- cout<<word[k-1];
- return 0;
- }
- if(k>=3)
- if(word!="DNA"&&word!="ROF"&&word!="EHT")
- cout<<word[k-1];
- return 0;
- }
- int main()
- {
- int i,j;
- cin>>n;
- getline(cin,a);
- for(j=1;j<=n;j++)
- {
- getline(cin,a);
- //ans="";
- al=a.length()-1;
- i=0;
- a=z(a);
- //cout<<a;
- while(i<=al)
- {
- if(a[i]==' '||a[i]=='/n')
- getl(i-1);
- i++;
-
- }
- getl(al);
- cout<<endl;
- }
- cin.close();
- cout.close();
- return 0;
- }