半自动写测试点代码
2025-01-20 19:09:02
发布于:北京
此代码以A+B problem为例:
#include<bits/stdc++.h>
using namespace std;
string name;
void run_code(int x){
int a,b,s;
cin >> a >> b;
string filename = name + to_string(x) + ".in";
freopen(filename.c_str(),"w",stdout);
cout << a << ' ' << b;
s = a + b; //更新自动计算部分
filename = name + to_string(x) + ".out";
freopen(filename.c_str(),"w",stdout);
cout << s;
fclose(stdout);
}
int main(){
int n;
cin >> n >> name;
for(int i = 1;i <= n;i++){
run_code(i);
}
}
样例组:
样例输入:
3 problem
1 2
1000 1000
10000 10000
样例输出:
problem1.in
1 2
problem1.out
3
problem2.in
1000 1000
problem2.out
2000
problem3.in
10000 10000
problem3.out
20000
更新日志:
上传初始版本
修改错误
将效率提高(自动计算结果)和自定义名字
全部评论 4
2025-01-20 来自 广东
0半自动👍
2025-01-20 来自 湖南
0百分之自动
2025-01-20 来自 北京
1
顶
2025-01-20 来自 浙江
0厉害!👍
2025-01-20 来自 浙江
0会用吗?
2025-01-20 来自 北京
0更新了
2025-01-20 来自 北京
0不会...
2025-01-20 来自 浙江
0
有帮助,赞一个