【模板库】对拍

我之前一直是用.bat文件进行对拍,代码如下:

@echo off
:rep
echo running SJ.exe
SJ.exe > 11input.in
echo running bc.exe
bc.exe < 11input.in > 12bc.out
echo running me.exe
me.exe < 11input.in > 12me.out
fc 12me.out 12bc.out > nul
if not errorlevel 1 goto rep

但有一个我很想实现的功能:对拍时显示运行时间
于是今天考试的时候折腾了一下,搞出了下面这个东西:

#include<iostream>
#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<windows.h>
using namespace std;

int main(){
	time_t a,b;
	while (true) {
		system("SJ.exe > 11input.in");
		
		a = clock();
		system("bc.exe < 11input.in > 12bc.out");
		b = clock(); printf("bc.exe cost %dms\n",b-a); 
		
		a = clock();
		system("me.exe < 11input.in > 12me.out");
		b = clock(); printf("me.exe cost %dms\n",b-a); 
		
		int tmp = system("fc 12bc.out 12me.out > result.txt");
		if (tmp == 1) system("taskkill /F /IM check.exe");
		cout<<endl<<endl;
	}
	return 0;
}

主要是应用了clock()和system()函数
要背住的东西也只有:”taskkill /F /IM check.exe”
运行效果如下:
check_cpp
感觉很不错,用了多少时间一目了然
因为调用了system()所以时间不是特别准,需要减去20ms的样子

22 thoughts to “【模板库】对拍”

  1. Hmm is anyone else having problems with the
    pictures on this blog loading? I’m trying to find out if its a problem on my end
    or if it’s the blog. Any suggestions would be greatly appreciated.

  2. I truly love your blog.. Very nice colors & theme. Did you develop
    this website yourself? Please reply back as I’m
    trying to create my very own blog and would love to find out where
    you got this from or what the theme is named. Many thanks!

  3. Howdy! This article could not be written much better! Reading through this post
    reminds me of my previous roommate! He continually kept preaching about this.

    I most certainly will send this article to him. Fairly certain he will have a good read.
    Thank you for sharing!

  4. Hello! I’m at work surfing around your blog from my new
    apple iphone! Just wanted to say I love reading through your blog and look forward to all your posts!

    Keep up the excellent work!

  5. I like the helpful info you provide to your articles.
    I’ll bookmark your weblog and test once more right here
    regularly. I’m fairly sure I will learn a lot of new stuff right here!

    Good luck for the next!

  6. Hello! This is kind of off topic but I need some help
    from an established blog. Is it difficult to set up your own blog?
    I’m not very techincal but I can figure things out pretty fast.
    I’m thinking about creating my own but I’m not sure where to start.
    Do you have any points or suggestions? Thanks

  7. Hey, I think your blog might be having browser compatibility issues.
    When I look at your website in Opera, it looks fine but when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up! Other then that, superb blog!

  8. I enjoy, result in I discovered exactly what I was taking a look for.
    You’ve ended my 4 day lengthy hunt! God Bless you man. Have a great
    day. Bye

  9. Heya! I’m at work browsing your blog from my new iphone! Just wanted to say I love reading through your blog and look forward to all your posts! Carry on the excellent work!

Leave a Reply

Your email address will not be published. Required fields are marked *