ACM 程序对拍
2016-07-24 12:24
405 查看
1.首先是要有一个产生数的程序,将产生的数据保存在data.txt中。
产生int型小数
产生随机的两位小数
产生字符串
相对于所需要的数据在这个基础上修改就可以了。
2.在你的程序与已经AC的程序上分别加上
3.在保存数据的位置新建一个文本文档
内容是
fc out1.txt out2.txt
pause
并把文本的扩展名改为.bat,点击运行就可以查看不同的测试数据了。
例如:
进行对拍会显示
显示不同的数据就可以拿来用了
产生int型小数
#include<cstdio> #include<cstdlib> #include<cstring> #include<time.h> int main() { freopen("data.txt", "w", stdout); srand(time(NULL)); //通过控制t的大小控制产生数的范围,控制n可以控制数据的产生量。 int t, n = 1000; while(n--) { printf("%d\n",rand()%t); } return 0; }
产生随机的两位小数
#include<cstdio> #include<cstdlib> #include<cstring> #include<time.h> int main() { freopen("data.txt", "w", stdout); srand(time(NULL)); int n = 1000; while(n--) { printf("%.2lf\n",rand()*1.0/100); } return 0; }
产生字符串
#include<cstdio> #include<cstdlib> #include<cstring> #include<time.h> int main() { freopen("data.txt", "w", stdout); srand(time(NULL)); int t, n = 1000; while(n--) { printf("%c\n",rand()%26 + 'A'); } return 0; }
相对于所需要的数据在这个基础上修改就可以了。
2.在你的程序与已经AC的程序上分别加上
freopen( "data.txt","r",stdin ); freopen( "1.txt","w",stdout );
freopen( "data.txt","r",stdin ); freopen( "2.txt","w",stdout );为了方便查找不同的测试数据,建议把读入的数据一并输出,方便查看。
3.在保存数据的位置新建一个文本文档
内容是
fc out1.txt out2.txt
pause
并把文本的扩展名改为.bat,点击运行就可以查看不同的测试数据了。
例如:
#include <stdio.h>和
int main() {
freopen( "data.txt","r",stdin ); freopen( "1.txt","w",stdout );
int a, b;
while (scanf("%d%d", &a, &b) != EOF) {
printf("%d %d ", a, b);
printf("%d\n", a + a);
}
return 0;
}
#include <stdio.h>
int main() {
freopen( "data.txt","r",stdin ); freopen( "2.txt","w",stdout );
int a, b;
while (scanf("%d%d", &a, &b) != EOF) {
printf("%d %d ", a, b);
printf("%d\n", a + b);
}
return 0;
}
进行对拍会显示
显示不同的数据就可以拿来用了
相关文章推荐
- FEDERATED未启动的问题
- bio nio aio
- Scala Set
- 09_Mybatis开发Dao方法——mapper代理开发规范
- 修复启动项
- nyoj 891 找点 【区间找点】
- UE4 材质的运算节点
- hdu 2544 最短路 (spfa)
- 自定义控件(视图)2期笔记11:View的滑动冲突之 概述
- [mysql] 一次sql耗时高引发报警的分析和处理
- viewpager触摸无效,viewpager触摸停止滑动
- Sealed,Internal关键字
- 统计学习方法六:支持向量机三(支持向量定量理解和算法总结)
- 欢迎使用CSDN-markdown编辑器
- 【Unity3D】AR应用中,关于东南西北方位的判断。
- Linux下挂载Windows共享目录
- json的操作应用实例
- 2016windows(10) wamp 最简单30分钟thrift入门使用讲解,实现php作为服务器和客户端的hello world
- redis结合php
- HDU 5726-D-GCD- RMQ+二分