zoukankan      html  css  js  c++  java
  • 出题造数据模板

    写文件和读文件

    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;
    
    }
    
    
  • 相关阅读:
    剑指47 礼物的最大价值
    剑指46 把数字转化成字符串
    剑指41:数据流中的中位数
    剑指39 数组中出现次数超过半数的数
    centos 7关闭与启用防火墙,开放端口,常用命令介绍
    用docker swarm搭建docker集群
    centos 7离线安装docker, 离线安装docker-compose
    centos 7离线安装harbor
    mysql-8安装教程(windows 64位)
    centos 7离线安装中文版GitLab
  • 原文地址:https://www.cnblogs.com/hunxuewangzi/p/15420598.html
Copyright © 2011-2022 走看看