返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. ifstream ifs;
  4. ofstream ofs;
  5. string str;
  6. int n;
  7. int main()
  8. {
  9.     cin>>n;
  10.     ifs.open("read.txt");
  11.     ofs.open("write.txt");
  12.     for(int i=0; i<n; i++)
  13.     {
  14.         getline(ifs, str);
  15.         for(int j=0, len=str.length(); j<len; j++)
  16.         {
  17.             char c=str[j];
  18.             if(j==0 || str[j-1]==' ')
  19.                 c-=32;
  20.             cout<<c;
  21.             ofs<<c;
  22.         }
  23.         cout<<'\n';
  24.         ofs<<'\n';
  25.     }
  26.     return 0;
  27. }
複製代碼

TOP

返回列表