zoukankan      html  css  js  c++  java
  • 无限对拍程序

    折叠代码之后博客就变短了好多呢。

    like this
    #include<bits/stdc++.h>
    #include<windows.h>
    using namespace std;
    
    int cas;
    
    int main(){
        while(1){
            Sleep(50);
            system("data.exe");//生成数据
            system("std.exe");//你的两份代码的exe文件1
            system("test.exe");//你的两份代码的exe文件2
            printf("-----------Test Case %d----------
    ",++cas);
            if(system("fc test.out test.ans")) system("pause");
        }
        return 0;
    }
    
    这里还有一份不用freopen的对拍程序
    #include <cstdio>
    #include <cstdlib>
    #include <windows.h>
    using namespace std;
    
    int main()
    {
    	//For Windows
    	//对拍时不开文件输入输出
    	//当然,这段程序也可以改写成批处理的形式
    	int tot = 0;
    	while(1)
    	{
    		printf("Test Data %d :
    ",++tot);
    		system("Create_Data.exe > data.in");//数据生成器将生成数据写入输入文件
    		system("my_code.exe < data.in > mine.out");//获取程序1输出
    		system("brute_force.exe < data.in > data2.out");//获取程序2输出
    		if(system("fc mine.out data2.out"))
    		{
       			//该行语句比对输入输出
    			//fc返回0时表示输出一致,否则表示有不同处
    			system("pause");//方便查看不同处
    			//该输入数据已经存放在data.in文件中,可以直接利用进行调试
    		}
    	}
    }
    
    无注释版本
    #include <cstdio>
    #include <cstdlib>
    #include <windows.h>
    using namespace std;
    
    int main()
    {
    	int tot = 0;
    	while(1)
    	{
    		printf("Test Data %d :
    ",++tot);
    		system("Create_Data.exe > data.in");
    		system("my_code.exe < data.in > mine.out");
    		system("brute_force.exe < data.in > data2.out");
    		if(system("fc mine.out data2.out"))
    			system("pause");
    	}
    }
    
    生成数据
    //12252024832524
    #include <ctime>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #define TT template<typename T>
    using namespace std; 
    
    typedef long long LL;
    const int MAXN = 100005;
    int n;
    
    LL Read()
    {
    	LL x = 0,f = 1;char c = getchar();
    	while(c > '9' || c < '0'){if(c == '-')f = -1;c = getchar();}
    	while(c >= '0' && c <= '9'){x = (x*10) + (c^48);c = getchar();}
    	return x * f;
    }
    TT void Put1(T x)
    {
    	if(x > 9) Put1(x/10);
    	putchar(x%10^48);
    }
    TT void Put(T x,char c = -1)
    {
    	if(x < 0) putchar('-'),x = -x;
    	Put1(x); if(c >= 0) putchar(c);
    }
    TT T Max(T x,T y){return x > y ? x : y;}
    TT T Min(T x,T y){return x < y ? x : y;}
    TT T Abs(T x){return x < 0 ? -x : x;}
    
    LL Rand(LL l,LL r){return (1ll * rand() * rand() * rand() + rand()) % (r-l+1) + l;}
    
    int main()
    {
    //	freopen(".in","r",stdin);
    //	freopen(".out","w",stdout);
    	srand(time(0));
    	
    	return 0;
    }
    

    注意文件名不要重名,哪怕后缀名不一样也不行。

  • 相关阅读:
    C# 不用添加WebService引用,调用WebService方法
    贪心 & 动态规划
    trie树 讲解 (转载)
    poj 2151 Check the difficulty of problems (检查问题的难度)
    poj 2513 Colored Sticks 彩色棒
    poj1442 Black Box 栈和优先队列
    啦啦啦
    poj 1265 Area(pick定理)
    poj 2418 Hardwood Species (trie树)
    poj 1836 Alignment 排队
  • 原文地址:https://www.cnblogs.com/PPLPPL/p/13569291.html
Copyright © 2011-2022 走看看