记录编号 | 169937 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | [暑假培训2012] 单词缩写 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.008 s | ||
提交时间 | 2015-07-11 15:17:28 | 内存使用 | 0.32 MiB | ||
#include <fstream> #include <string> #include <cstring> #include <sstream> #include <ctype.h> using namespace std; ifstream fin("abbreviation.in"); ofstream fout("abbreviation.out"); int main() { int n; char ch; //char str[1001]; string str,s,ans; stringstream st; fin>>n; /*while((fin>>str)) { ch=fin.get(); //fout<<str<<' '; if(str!="and"&&str!="for"&&str!="the"&&str!="And"&&str!="For"&&str!="The"&&str!="AND"&&str!="FOR"&&str!="THE"&&str!="ANd"&&str!="FOr"&&str!="THe"&&(str.length()>=3)) { if(str[0]>='a'&&str[0]<='z') str[0]-=32; s=s+str[0]; //fout<<s<<endl; if(ch==10||ch==13||ch==EOF) { fout<<s<<endl; int l; l=s.length(); s.erase(0,l); } else continue; } else continue; }*/ while((n--)+1) { getline(fin,str); st.clear(); st.str(str); while(st>>s) { int x=s.length(); for(int j=0;j<=x-1;j++) { if(s[j]>='A'&&s[j]<='Z') s[j]+='a'-'A'; } if (x<=2||s=="and"||s=="for"||s=="the") continue; s[0]=toupper(s[0]); fout<<s[0]; } fout<<endl; } fin.close(); fout.close(); return 0; }//Write by XPK