返回列表 發帖
  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.         char c;
  16.         for(int j=0;j<str.length();j++)
  17.         {
  18.             if(j==0 || str[j-1]==' ')
  19.                 c=str[j]32;
  20.             else
  21.                 c=str[j];
  22.             cout<<c;
  23.             ofs<<c;
  24.         }
  25.         cout<<endl;
  26.         ofs<<'\n';
  27.     }
  28.     return 0;
  29. }
複製代碼

TOP

返回列表