Younger brother's homework (hpu1164) and younger brother's homework hpu1164

Source: Internet
Author: User

Younger brother's homework (hpu1164) and younger brother's homework hpu1164

Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 74 Solved: 37
[Submit] [Status] [Web Board] Description

Your younger brother has just completed the assignment of "adding and subtracting less than 100". Please check it for him. The format of each question (including the answer of the younger brother) isA+B=COrA-B=C, WhereAAndBIs a non-negative integer not greater than 100 given in the job;CThe answer is calculated by the younger brother. It may be a non-negative integer not greater than 200, or a single character "? ", Indicating that he will not calculate.

Input

The input file contains no more than 100 lines and ends with a file Terminator. Each line contains a question. The format must comply with the preceding rules and does not contain any blank characters. All input integers do not contain leading 0.

Output

The output contains only one row, which contains a non-negative integer, that is, the number of correct answers.

Sample Input1 + 2 = 33-1 = 56 + 7 =? 99-0 = 99 Sample Output2HINT

Source

Hunan sixth College Computer Program Design Competition

#include<stdio.h>#include<string.h>int main(){int a,b,d,sum=0,len;    char s,c[4];    while(scanf("%d%c%d=%s",&a,&s,&b,c)!=EOF){    len=strlen(c);if(c[0]!='?')        {     if(len==1)d=c[0]-'0';            if(len==2)            d=(c[0]-'0')*10+c[1]-'0';            if(len==3)            d=(c[0]-'0')*100+(c[1]-'0')*10+c[2]-'0';            if(s=='+')            {                if(a+b==d)                sum++;            }            if(s=='-')            {                if(a-b==d)                sum++;            }        }    }    printf("%d\n",sum);    return 0; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.