openjudge使用指南.ppt

上传人:sh****n 文档编号:6391736 上传时间:2020-02-24 格式:PPT 页数:21 大小:816.31KB
返回 下载 相关 举报
openjudge使用指南.ppt_第1页
第1页 / 共21页
openjudge使用指南.ppt_第2页
第2页 / 共21页
openjudge使用指南.ppt_第3页
第3页 / 共21页
点击查看更多>>
资源描述
openjudge使用指南 几点说明 提交程序时必须采用从标准输入读取数据 向标准输出写入数据的方式 在C 程序中用 cin cout 在c程序中用scanf printf你的程序不能向标准输出写入任何多余的数据 否则将会得到 答案错误 WrongAnswer 的结果 你的程序不能从任何文件中输入 输出数据 否则将会得到 运行时错误 RuntimeError 或者 答案错误 WrongAnswer 的结果 注意 在G GCC程序中 main 函数的返回值类型必须是 整型 int 否则将得到 编译错误 compileerror 一定按照要求进行输入输出 errorError presentationerror输出格式不符合要求compileerror编译错误 输入输出格式 2020 2 24 10 ACM题目特点 由于ACM竞赛题目的输入数据和输出数据一般有多组 不定 并且格式多种多样 所以 如何处理题目的输入输出是对大家的一项最基本的要求 这也是困扰初学者的一大问题 下面 分类介绍 2020 2 24 11 一个超级简单的题目 ex 1 ProblemDescriptionYourtaskistocalculatea b InputTheinputwillconsistofaseriesofpairsofintegersaandb separatedbyaspace onepairofintegersperline OutputForeachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline andwithonelineofoutputforeachlineininput Sampleinput151020Sampleoutput630 2020 2 24 12 输入第一类 输入不说明有多少个InputBlock 以EOF为结束标志 参见 ex 1 2020 2 24 13 ex 1源代码 includeintmain inta b while scanf d d 2020 2 24 14 本类输入解决方案 C语法 while scanf d d a b EOF C 语法 while cin a b 2020 2 24 15 说明 Scanf函数返回值就是读出的变量个数 如 scanf d d 如果a和b都被成功读入整数 那么scanf的返回值就是2 如果只有a被成功读入整数 返回值为1 如果a和b都未被成功读入整数 返回值为0 如果遇到错误或遇到endoffile 返回值为EOFEOF是一个预定义的常量 等于 1 2020 2 24 16 输入第二类 输入一开始就会说有N个InputBlock 下面接着是N个InputBlock ex 2ProblemDescriptionYourtaskistocalculatea b InputInputcontainsanintegerNinthefirstline andthenNlinesfollow Eachlineconsistsofapairofintegersaandb separatedbyaspace onepairofintegersperline OutputForeachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline andwithonelineofoutputforeachlineininput Sampleinput2151020Sampleoutput630 2020 2 24 17 ex 2源代码 includeintmain intn i a b scanf d 2020 2 24 18 本类输入解决方案 C语法 scanf d i 2020 2 24 19 输入第三类 输入不说明有多少个InputBlock 但以某个特殊输入为结束标志 ex 3ProblemDescriptionYourtaskistocalculatea b InputInputcontainsmultipletestcases Eachtestcasecontainsapairofintegersaandb onepairofintegersperline Atestcasecontaining00terminatestheinputandthistestcaseisnottobeprocessed OutputForeachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline andwithonelineofoutputforeachlineininput Sampleinput15102000Sampleoutput630 2020 2 24 20 ex 3源代码 includeintmain inta b while scanf d d 上面的程序有什么问题 杜绝低级错误 2020 2 24 21 本类输入解决方案 如果最后一行是以一个0结尾则 C语法 while scanf d n n 0 C 语法 while cin n n 0
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 课件教案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!