对拍基础模板

1 :loop
2   c.exe
3   a.exe
4   b.exe
5   fc a.out b.out
6   if %errorlevel%==0 goto loop
7 pause

批处理文件(.bat)

 

以排序为例

a.cpp

 1 #include <iostream>
 2 using namespace std;
 3 int i,j,a[100005],n;
 4 int main()
 5 {
 6     freopen("a.in","r",stdin);
 7     freopen("a.out","w",stdout);
 8     scanf("%d",&n);
 9     for (i=1; i<=n; i++) cin>>a[i];
10     for (i=1; i<=n; i++)
11       for (j=i+1; j<=n; j++)
12         if (a[i]<a[j])
13           swap(a[i],a[j]);
14     for (i=1; i<=n; i++) cout<<a[i]<<' ';
15     return 0;
16 }

 

b.cpp

 1 #include <iostream>
 2 #include <algorithm>
 3 using namespace std;
 4 int i,j,a[100005],n;
 5 int cmp(int i,int j) {return i>j;}
 6 int main()
 7 {
 8     freopen("a.in","r",stdin);
 9     freopen("b.out","w",stdout);
10     scanf("%d",&n);
11     for (i=1; i<=n; i++) cin>>a[i];
12     sort(a+1,a+n+1,cmp);
13     for (i=1; i<=n; i++) cout<<a[i]<<' ';
14     return 0;
15 }

c.cpp

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <ctime>
 4 using namespace std;
 5 int main()
 6 {
 7     freopen("a.in","w",stdout);
 8     srand((unsigned)time(NULL));
 9     int n=rand()%1000+1;
10     cout<<n<<endl;
11     for (int i=1; i<=n; i++)
12       cout<<rand()%10000+1<<' ';
13     return 0;
14 }

原文见 快乐永恒 ~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值