出题造数据模板

写文件和读文件

freopen("1.in", "r", stdin); //读
freopen("1.out", "w", stdout); //写
freopen("xx//1.out", "w", stdout); //表示在xx文件下面写1.out文件

数据都在\(xz\)文件下面

造读入数据

#include<bits/stdc++.h>
#define fi first
#define se second
#define debug cout<<"I AM HERE"<<endl;
using namespace std;
typedef long long ll;
const int maxn=1e6+5,inf=0x3f3f3f3f,mod=1e6+1;
const double eps=1e-6;
mt19937 rnd(time(0));
int a,b;
void pr(){
    
}
signed main(){
    // 造 a-b组数据
    for(int i=a;i<=b;i++){
        char s[]="xz\\ .in";
//        char s2[]="xz\\ .out";
        char t[]="xz\\  .in";
//        char t2[]="xz\\  .out";
        if(i<10){
            char ch=i+'0';
            s[3]=ch;
//            freopen(s,"r",stdin);
            freopen(s,"w",stdout);
        }else{
            char ch1=i/10+'0';
            char ch2=i%10+'0';
//            t2[3]=t[3]=ch1;
//            t2[4]=
            t[3]=ch1;
            t[4]=ch2;
//            freopen(t,"r",stdin);
            freopen(t,"w",stdout);
        }
        pr();// 输出数据

//        fclose(stdin);
        fclose(stdout);

    }
    return 0;
}

造读出数据

#include<bits/stdc++.h>
#define fi first
#define se second
#define debug cout<<"I AM HERE"<<endl;
using namespace std;
typedef long long ll;
const int maxn=1e6+5,inf=0x3f3f3f3f,mod=1e6+1;
const double eps=1e-6;
mt19937 rnd(time(0));
int a,b;
void solve(){

}
signed main(){
    for(int i=a;i<=b;i++){
        char s[]="xz\\ .in";
        char s2[]="xz\\ .out";
        char t[]="xz\\  .in";
        char t2[]="xz\\  .out";
        if(i<10){
            char ch=i+'0';
            s2[3]=s[3]=ch;
            freopen(s,"r",stdin);
            freopen(s2,"w",stdout);
        }else{
            char ch1=i/10+'0';
            char ch2=i%10+'0';
            t2[3]=t[3]=ch1;
            t2[4]=t[4]=ch2;
            freopen(t,"r",stdin);
            freopen(t2,"w",stdout);
        }
        solve();
        fclose(stdin);
        fclose(stdout);
    }
    return 0;

}

上一篇:杨辉三角 删除字符 加密解密


下一篇:进程结束调用接口exit、_exit、return的区别