出題造資料模板
阿新 • • 發佈:2021-10-18
寫檔案和讀檔案
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; }