跳到正文

剪贴板

剪贴板 m4tlkazp

原文
剪贴板信息

剪贴板信息

收录
更新

自创数据生成器

C++
#include<bits/stdc++.h>
using namespace std;

void read_num(int x){//用户可以从这里输入所有想保存至文档的数字或字符
	cin>>x;//输入程序可自定义
}

void write_file(int x){//用户可以从这里输入所有想保存至文档的数字或字符
	cout<<x;//输出程序可自定义
}

int main(){
	//一定要加上freopen!!!
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
	//调用函数
   read_num(1);
	write_file(1);

	return 0;
}

或

Python
'''
数据生成器
可以用于多种情况
无需下载库
只需使用python内置的open()函数即可

code by CrossBow_EXE
'''

import random


def make_str(n):  # 字符串处理
    if 1 <= n and n <= 9:
        ans = '00'+str(n)
    if 10 <= n and n <= 99:
        ans = '0'+str(n)
    if 100 <= n and n <= 999:
        ans = str(n)
    return ans


def open_file(n, m):  # 创建m-n+1个编号为tn~tm的in+out文件
    for i in range(n, m+1):
        tmp = make_str(i)
        f = open('t'+tmp+'.in', 'w')
        print('', file=f)
        f.close()
        f = open('t'+tmp+'.out', 'w')
        print('', file=f)
        f.close()


def do_randList(n, m):
    List = []
    for i in range(1, m-n+2):
        List.append(n+i-1)
    return List


def randNum(list_, file):
    f = open(file, 'w')
    print(random.choice(list_), file=f)
    f.close()