C++#include <bits/stdc++.h>
using namespace std;
// 通用函数:根据编号生成对应的.in和.out文件,并写入内容(直到读取到###为止)
void writeFiles(int num) {
// 生成文件名(如"1.in"、"1.out")
string inFile = to_string(num) + ".in";
string outFile = to_string(num) + ".out";
// 写入.in文件
ofstream outIn(inFile);
string s;
while (true) {
getline(cin, s);
if (s == "###") break;
outIn << s << "\n";
}
// 写入.out文件
ofstream outOut(outFile);
while (true) {
getline(cin, s);
if (s == "###") break;
outOut << s << "\n";
}
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n; // 测试点个数
cin >> n;
// 读取cin后的换行符,避免影响后续getline
cin.ignore(numeric_limits<streamsize>::max(), '\n');
for (int x = 1; x <= n; ++x) {
writeFiles(x);
}
return 0;
}