openjudge使用指南.ppt_第1页
openjudge使用指南.ppt_第2页
openjudge使用指南.ppt_第3页
openjudge使用指南.ppt_第4页
openjudge使用指南.ppt_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

openjudge使用指南 几点说明 提交程序时必须采用 从标准输入读取数据,向标准输出写入数 据的方式。 在C+程序中用 “cin ”、“cout” 在c程序中用scanf, printf 你的程序不能向标准输出写入任何多余的数据,否则将会得到“ 答案错误 (Wrong Answer)”的结果。 你的程序不能从任何文件中输入/输出数据,否则将会得到“运行 时错误(Runtime Error)”或者“答案错误 (Wrong Answer)”的结 果。 注意:在G+/GCC程序中,main()函数的返回值类型必须是“整 型(int)”,否则将得到“编译错误(compile error)”。 一定按照要求进行输入输出; error Error presentation error 输出格式不符合要求 compile error 编译错误 输入输出格式 *10 ACM题目特点 由于ACM竞赛题目的输入数据和输 出数据一般有多组(不定),并且格 式多种多样,所以,如何处理题目的 输入输出是对大家的一项最基本的要 求。这也是困扰初学者的一大问题。 下面,分类介绍: *11 一个超级简单的题目(ex-1): Problem Description Your task is to calculate a + b. Input The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line. Output For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input. Sample input 1 5 10 20 Sample output 6 30 *12 输入第一类: 输入不说明有多少个Input Block, 以EOF为结束标志。 参见:ex-1. *13 ex-1源代码: #include int main() int a,b; while(scanf(“%d %d“, return 0; *14 本类输入解决方案: C语法: while(scanf(“%d %d“, 如果a和b都被成功读入整数,那么scanf的返回值就 是2; 如果只有a被成功读入整数,返回值为1; 如果a和b都未被成功读入整数,返回值为0; 如果遇到错误或遇到end of file,返回值为EOF 2.EOF是一个预定义的常量,等于-1。 *16 输入第二类: 输入一开始就会说有N个Input Block,下面接着是N个Input Block。 ex-2 Problem Description Your task is to calculate a + b. Input Input contains an integer N in the first line, and then N lines follow. Each line consists of a pair of integers a and b, separated by a space, one pair of integers per line. Output For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input. Sample input 2 1 5 10 20 Sample output 6 30 *17 ex-2源代码: #include int main() int n,i,a,b; scanf(“%d“, for(i=0;i n; for( i=0 ; i int main() int a,b; while(scanf(“%d %d“, return 0; 上面的程序有什么问题?杜绝低级错误!

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论