返回列表 發帖
本帖最後由 侯宣仲 於 2024-9-11 19:55 編輯
  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.     ifs.open("read.txt");
  10.     ofs.open("write.txt");
  11.     cin>>n;
  12.     for(int i=0;i<n;i++)
  13.     {
  14.         getline(ifs,str);
  15.         for(int j=0;j<n;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.         }
  24.         cout<<endl;
  25.         ofs<<endl;
  26.     }
  27.    
  28.     return 0;
  29. }
複製代碼

TOP

返回列表