Sinh test (input và output đồng thời)
#include<bits/stdc++.h>
using namespace std;
long long Rand(long long l, long long h)
{
return l + ((long long)rand() * (RAND_MAX + 1) * (RAND_MAX + 1) * (RAND_MAX + 1) +
(long long)rand() * (RAND_MAX + 1) * (RAND_MAX + 1) +
(long long)rand() * (RAND_MAX + 1) +
rand()) % (h - l + 1);
}
void write(string t,string t1){
ofstream fileOutput(t);
ofstream fileOutput1(t1);
if(fileOutput.fail()){
cout<<"Cannot open file at "<<t<<'\n';
}
long long tmp=Rand(1,1000);
fileOutput<<tmp<<'\n';
if(tmp<=2) fileOutput1<<tmp+2<<'\n';
else fileOutput1<<tmp-2<<'\n';
}
int main(){
srand(time(NULL));
int i;
string s="",s1="";
for(i=0;i<100;i++){
s="C:/New folder/aka/"+to_string(i+1)+".inp";
s1="C:/New folder/aka_1/"+to_string(i+1)+".out";
write(s,s1);
}
return 0;
}
using namespace std;
long long Rand(long long l, long long h)
{
return l + ((long long)rand() * (RAND_MAX + 1) * (RAND_MAX + 1) * (RAND_MAX + 1) +
(long long)rand() * (RAND_MAX + 1) * (RAND_MAX + 1) +
(long long)rand() * (RAND_MAX + 1) +
rand()) % (h - l + 1);
}
void write(string t,string t1){
ofstream fileOutput(t);
ofstream fileOutput1(t1);
if(fileOutput.fail()){
cout<<"Cannot open file at "<<t<<'\n';
}
long long tmp=Rand(1,1000);
fileOutput<<tmp<<'\n';
if(tmp<=2) fileOutput1<<tmp+2<<'\n';
else fileOutput1<<tmp-2<<'\n';
}
int main(){
srand(time(NULL));
int i;
string s="",s1="";
for(i=0;i<100;i++){
s="C:/New folder/aka/"+to_string(i+1)+".inp";
s1="C:/New folder/aka_1/"+to_string(i+1)+".out";
write(s,s1);
}
return 0;
}
Nhận xét
Đăng nhận xét