我之前一直是用.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”
运行效果如下:
感觉很不错,用了多少时间一目了然
因为调用了system()所以时间不是特别准,需要减去20ms的样子
It’s very straightforward to find out any topic
on web as compared to books, as I found this post at this site.
Highly energetic blog, I liked that bit.
Will there be a part 2?
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.
This is a topic that is close to my heart…
Cheers! Where are your contact details though?
Your means of telling the whole thing in this article is actually nice, all be able to effortlessly be
aware of it, Thanks a lot.
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!
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!
WOW just what I was looking for. Came here by searching for ps4 games
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!
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!
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
I for all time emailed this weblog post page to all my friends, for the reason that if like to read it next my links will too.
you might have an incredible weblog here! would you prefer to make some invite posts on my blog?
Thanks for sharing your thoughts about coconut oil.
Regards
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!
What’s up, I wish for to subscribe for this blog to obtain most up-to-date updates, so where can i
do it please help out.
What’s up everyone, it’s my first pay a visit at this website,
and piece of writing is genuinely fruitful for me, keep up posting these articles or reviews.
When some one searches for his essential thing,
so he/she wants to be available that in detail, thus that thing is maintained over here.
Wow! Finally I got a weblog from where I be able to actually get valuable facts regarding my study and knowledge.
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
For the reason that the admin of this web site is working, no question very rapidly it will
be well-known, due to its feature contents.
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!