对拍基础模板
来源:互联网 发布:艾瑞网数据查询 编辑:程序博客网 时间:2024/05/04 21:58
1 :loop2 c.exe3 a.exe4 b.exe5 fc a.out b.out6 if %errorlevel%==0 goto loop7 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 }
原文见 快乐永恒 ~