专栏文章
造数据点机器
个人记录参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @minjvypv
- 此快照首次捕获于
- 2025/12/02 03:36 3 个月前
- 此快照最后确认于
- 2025/12/02 03:36 3 个月前
更新造输出数据
造输入数据代码:
CPP#include <bits/stdc++.h>//IAKCSP
#include <windows.h>
#include <winuser.h>
/*
*/
using namespace std;
#define int long long
#define N 55
void is_file(string where);
vector<pair<int,int>> a(N+10);
vector<int> s;
int n;
map<int,int> mp;
int count_line(string name){
ifstream file(name);
string line;
int count=0;
while(getline(file,line)){
count++;
}
return count;
}
void creat_txt(string name){
// ofstream file;
// file.open(name,0x02);
// file.colse();
}
void write_file(string name,string thing){
// if(!is_file(name)){
// creat_txt(name);
// }
std::ofstream outputFile;
name=name;
outputFile.open(name.c_str());
outputFile<<thing<<std::endl;
outputFile.close();
}
string read_line(string name,int line){
string dew=to_string(line);
string fullPath=name;
ifstream file(fullPath);
if(!file.is_open()){
return "";
}
string txt="",meiyong;
for(int i=0;i<count_line(fullPath);i++) {
if(i==line-1){
getline(file,txt);
}else{
getline(file,meiyong);
}
}
file.close();
return txt;
}
//bool is_file(string where){
// string fullPath=where;
// ifstream file(fullPath);
// if(!file.is_open()){
// return false;
// }return true;
//}
void write_line(string name,string thing,int line){
string nr="";
if(line>=998){
return;
}
string n=name;
for(int i=0;i<count_line(n);i++){
if(i!=line-1)nr=nr+read_line(name,i+1)+"\n";
else{
nr=nr+thing+"\n";
}
}
write_file(name,nr);
return;
}
int r(int left,int right){
// indo("use r():[rand]begin-"+to_string(left)+" end-"+to_string(right));
auto now = std::chrono::high_resolution_clock::now();
auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
std::mt19937 generator(static_cast<unsigned int>(microseconds));
std::uniform_int_distribution<int> distribution(left, right);
return distribution(generator);
}
string outans="";
void solve(){
outans="";
for(int i=0;i<s.size();i++){
int randValue=r(a[s[i]].first,a[s[i]].second);
outans+=to_string(randValue)+" ";
// cout<<randValue<<" ";
Sleep(1);
}
}
signed main(){
srand(time(0));
printf("使用之前请先输入生成的数据数量.\n");
printf("使用方式:第一行输入有多少种(n种)不同范围的数据,(n<=25).\n");
printf("使用方式:第二行输入n个这样的数据的范围.默认第i个数据的表示字符为char('a'+i)\n");
printf("使用方式:第三行输入多个[数量]char('a'+i),表示数据.\n");
printf("使用方式:最后代码会根据第三行将样例输出XX.in.\n");
printf("实例:输入 : 3 \n0 99\n1 10\n0 1\na b 7c\n输出: 54 7 1 0 0 0 1 1 0 0 1\n");
printf("最后数据会存储在OUTX.out内\n\n");
printf("INPUT::");
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int _=1;
// string p="exam"+to_string(_)+".in";
// string p1="exam"+to_string(_)+".in";
// freopen(p.c_str(),"r",stdin);
// freopen(p1.c_str(),"w",stdout);
cin>>_;
int nn=_;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i].first>>a[i].second;
}
string k;
while (cin>>k){
if(k.size()>=2){
char ch=k[k.size()-1];
k.erase(k.begin()+k.size()-1);
int pp=stoi(k);
for(int i=0;i<pp;i++){
s.push_back(ch-'a');
}
}
else s.push_back(k[0]-'a');
}
while(_--){
solve();
// cout<<outans<<"<\n";
write_file("Val"+to_string(nn-_)+".in",outans);
}
}
造输出数据代码:
CPP#include <bits/stdc++.h>//IAKCSP
//#include <windows.h>
/*
检查,根据我的码风,说仔细点,对于每处错误给出此出错误的正确代码
,示范,改正,以及错误分析。
*/
using namespace std;
#define int long long
#define N 1010
void solve(){
;
}
int count_line(string name){
ifstream file(name);
string line;
int count=0;
while(getline(file,line)){
count++;
}
return count;
}
void creat_txt(string name){
// ofstream file;
// file.open(name,0x02);
// file.colse();
}
void write_file(string name,string thing){
// if(!is_file(name)){
// creat_txt(name);
// }
std::ofstream outputFile;
name=name;
outputFile.open(name.c_str());
outputFile<<thing<<std::endl;
outputFile.close();
}
string read_line(string name,int line){
string dew=to_string(line);
string fullPath=name;
ifstream file(fullPath);
if(!file.is_open()){
return "";
}
string txt="",meiyong;
for(int i=0;i<count_line(fullPath);i++) {
if(i==line-1){
getline(file,txt);
}else{
getline(file,meiyong);
}
}
file.close();
return txt;
}
//bool is_file(string where){
// string fullPath=where;
// ifstream file(fullPath);
// if(!file.is_open()){
// return false;
// }return true;
//}
void write_line(string name,string thing,int line){
string nr="";
if(line>=998){
return;
}
string n=name;
for(int i=0;i<count_line(n);i++){
if(i!=line-1)nr=nr+read_line(name,i+1)+"\n";
else{
nr=nr+thing+"\n";
}
}
write_file(name,nr);
return;
}
int r(int left,int right){
// indo("use r():[rand]begin-"+to_string(left)+" end-"+to_string(right));
auto now = std::chrono::high_resolution_clock::now();
auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
std::mt19937 generator(static_cast<unsigned int>(microseconds));
std::uniform_int_distribution<int> distribution(left, right);
return distribution(generator);
}
signed main(){
// freopen("abba.in","r",stdin);
// freopen("abba.out","w",stdout);
// ios::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
printf("造输出数据,输出数据数量,自动读取本文件夹下的OUTX.out文件并输出\n\nINPUT::");
int _=1;
cin>>_;
int nn=_;
while(_--){
string s=read_line("Val"+to_string(nn-_)+".in",1);
write_file("GET.in",s);
cout<<s<<"\n";
system("abc.exe");
string oldname="GET.out";
string newname="Val"+to_string(nn-_)+".out";
rename(oldname.c_str(),newname.c_str());
}
}
实例:对于A+1Problem;
输入x,输出x+1的测试点:
在造输入中输入:
10(假如你需要10组数据)
1(1种变量x)
1 100(x的范围,左包右包)
a(输出格式)
(其中5a表示5遍变量x,自动加空格)
在造输出中输入:
10
[就会自动生成]
最后把Val1.in,Val1.out,Val2.in,Val2.out ...
打包成zip就可以啦
不喜勿喷
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...