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

TOP

返回列表