本帖最後由 李彣 於 2024-9-11 20:01 編輯
- #include<bits/stdc++.h>
- using namespace std;
- ifstream ifs;
- ofstream ofs;
- int n;
- string str;
- int main()
- {
- ifs.open("read.txt");
- ofs.open("write.txt");
- cin>>n;
- for(int i=0;i<n;i++)
- {
- getline(ifs,str);
- for(int j=0;i<str.length();i++)
- {
- char c=str[j];
- if(j==0 || str[j-1]==' ')
- {
- c-=32;
- }
- cout<<c;
- ofs<<c;
- }
- cout<<'\n';
- ofs<<"\n";
- }
- return 0;
- }
複製代碼 |