弟弟的作业

来源:互联网 发布:开源团购源码 编辑:程序博客网 时间:2024/04/29 10:13
<center style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 23.636363983154297px; line-height: 47.99715805053711px;"><h2 style="margin: 0px; font-family: inherit; color: blue; text-rendering: optimizelegibility; font-size: 24px; line-height: 36px;"> 弟弟的作业</h2><span class="green" style="color: green;">Time Limit: </span>1 Sec  <span class="green" style="color: green;">Memory Limit: </span>128 MB<span class="green" style="color: green;">Submit: </span>26  <span class="green" style="color: green;">Solved: </span>20[<a target=_blank href="http://www.nynuacm.com/hustoj/JudgeOnline/submitpage.php?cid=1021&pid=1&langmask=0" style="color: rgb(26, 92, 200); text-decoration: none;">Submit</a>][<a target=_blank href="http://www.nynuacm.com/hustoj/JudgeOnline/problemstatus.php?id=1207" style="color: rgb(26, 92, 200); text-decoration: none;">Status</a>][<a target=_blank href="http://www.nynuacm.com/hustoj/JudgeOnline/bbs.php?pid=1207&cid=1021" style="color: rgb(26, 92, 200); text-decoration: none;">Web Board</a>] [<a target=_blank href="http://www.nynuacm.com/hustoj/JudgeOnline/admin/problem_edit.php?id=&getkey=6670A93DB7" style="color: rgb(26, 92, 200); text-decoration: none;">Edit</a>] [<a target=_blank href="http://www.nynuacm.com/hustoj/JudgeOnline/admin/quixplorer/index.php?action=list&dir=1207&order=name&srt=yes" style="color: rgb(26, 92, 200); text-decoration: none;">TestData</a>]</center><h2 style="margin: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizelegibility; font-size: 24px; line-height: 36px;">Description</h2><div class="content" style="background-image: none; background-attachment: scroll; background-color: rgb(228, 240, 248); font-family: 'Times New Roman'; font-size: 14px; line-height: 24px; height: auto; margin: 0px; padding: 0px 20px; color: rgb(51, 51, 51); background-position: 0px 0px; background-repeat: repeat repeat;"><p style="margin-top: 0px; margin-bottom: 9px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;"><span lang="EN-US" style="font-size: 10pt; font-family: 宋体;">你的弟弟刚做完了</span><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">“100</span><span lang="EN-US" style="font-size: 10pt; font-family: 宋体;">以内数的加减法</span><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">”</span><span lang="EN-US" style="font-size: 10pt; font-family: 宋体;">这部分的作业,请你帮他检查一下。每道题目(包括弟弟的答案)的格式</span><span style="font-size: 10pt; font-family: 宋体;">为</span><em><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">a</span></em><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">+<em>b</em>=<em>c</em></span><span style="font-size: 10pt; font-family: 宋体;">或者</span><em><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">a</span></em><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">-<em>b</em>=<em>c</em></span><span style="font-size: 10pt; font-family: 宋体;">,其中</span><em><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">a</span></em><span style="font-size: 10pt; font-family: 宋体;">和</span><em><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">b</span></em><span lang="EN-US" style="font-size: 10pt; font-family: 宋体;">是作业中给出的,均为不超过</span><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">100</span><span lang="EN-US" style="font-size: 10pt; font-family: 宋体;">的非负整数</span><span style="font-size: 10pt; font-family: 宋体;">;</span><em><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">c</span></em><span lang="EN-US" style="font-size: 10pt; font-family: 宋体;">是弟弟算出的答案,可能是不超过</span><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">200</span><span lang="EN-US" style="font-size: 10pt; font-family: 宋体;">的非负整数,也可能是单个字符</span><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">"</span><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';">?</span><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">"</span><span lang="EN-US" style="font-size: 10pt; font-family: 宋体;">,表示他不会算。</span></p><p style="margin-top: 0px; margin-bottom: 9px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;"></p></div><h2 style="margin: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizelegibility; font-size: 24px; line-height: 36px;">Input</h2><div class="content" style="background-image: none; background-attachment: scroll; background-color: rgb(228, 240, 248); font-family: 'Times New Roman'; font-size: 14px; line-height: 24px; height: auto; margin: 0px; padding: 0px 20px; color: rgb(51, 51, 51); background-position: 0px 0px; background-repeat: repeat repeat;"><p style="margin-top: 0px; margin-bottom: 9px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;"><span lang="EN-US" style="font-size: 10pt; font-family: 宋体;">输入文件包含不超过</span><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">100</span><span lang="EN-US" style="font-size: 10pt; font-family: 宋体;">行,以文件结束符结尾。每行包含一道题目,格式保证符合上述规定,且不包含任何空白字符。输入的所有整数均不含前导</span><span lang="EN-US" style="font-size: 10pt; font-family: 'Times New Roman';">0</span><span lang="EN-US" style="font-size: 10pt; font-family: 宋体;">。</span></p><p style="margin-top: 0px; margin-bottom: 9px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;"></p></div><h2 style="margin: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizelegibility; font-size: 24px; line-height: 36px;">Output</h2><div class="content" style="background-image: none; background-attachment: scroll; background-color: rgb(228, 240, 248); font-family: 'Times New Roman'; font-size: 14px; line-height: 24px; height: auto; margin: 0px; padding: 0px 20px; color: rgb(51, 51, 51); background-position: 0px 0px; background-repeat: repeat repeat;"><p style="margin-top: 0px; margin-bottom: 9px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;"><span lang="EN-US" style="font-size: 10pt; font-family: 宋体;">输出仅一行,包含一个非负整数,即弟弟答对的题目数量。</span></p><p style="margin-top: 0px; margin-bottom: 9px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;"></p></div><h2 style="margin: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizelegibility; font-size: 24px; line-height: 36px;">Sample Input</h2><pre class="content" style="padding: 8.5px; font-family: Menlo, Monaco, 'Courier New', monospace; font-size: 12.025px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; margin-top: 0px; margin-bottom: 9px; line-height: 18px; background-color: rgb(245, 245, 245); border: 1px solid rgba(0, 0, 0, 0.14902); white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><span class="sampledata" style="background-image: none; background-attachment: scroll; background-color: rgb(141, 184, 255); font-family: monospace; font-size: 18px; white-space: pre; background-position: 0px 0px; background-repeat: repeat repeat;">1+2=33-1=56+7=?99-0=99</span>

Sample Output

2

#include<iostream>#include<stdio.h>#include<string.h>using namespace std;int main(){int a,b,c1;int count=0;char c[3];char  f;//1+2=3memset(c,'\0',sizeof(c));while(scanf("%d%c%d=%s",&a,&f,&b,&c)!=EOF){if(strcmp(c,"?")==0){continue;} if(f=='+'){sscanf(c,"%d",&c1);if(a+b==c1){               count++;   continue;}}  if(f=='-'){  sscanf(c,"%d",&c1);if(a-b==c1){               count++;   continue;}}}cout<<count<<endl;return 0;}

0 0
原创粉丝点击