Brother's Homework

Source: Internet
Author: User

1018: Brother's homework time limit:1 Sec Memory limit:128 MB
submit:413 solved:188
[Submit] [Status] [BBS] Description

Your brother just finished the "Plus and minus " part of the homework, please help him check it. The format of each topic (including the brother's answer) is a+b=c or a-b=c, where A and B are given in the assignment and are non-negative integers that do not exceed the number of;c is the brother to figure out the answer, may be not more than a non-negative integer, may be a single character "?" , which means he can't count.

Input

The input file contains no more than a few lines, ending with a file terminator. Each row contains a title that is guaranteed to conform to the above and does not contain any whitespace characters. All integers entered do not contain a leading 0.

Output

Output only one line, including a non-negative integer, that is, the number of questions the brother answered correctly.

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

! =eof Here you need to press two times Ctrl Z and then enter because here S is Char

int sscanf (const char *buffer,const char *format,[argument] ...); The data stored in buffer is formatted with the format Control string argument the selective setting string sscanf reads data from buffer and writes the data to the argument according to format.
#include <stdio.h>intMain () {inta,b,f,d,j,c,t= -, sum=0; Chars[101];  while(SCANF ("%s", &s)! =EOF) {        if(SSCANF (s),"%d+%d=%d", &a,&b,&c) = =3&AMP;&AMP;A+B==C)//Success returns the number of arguments{sum++; }        if(SSCANF (s),"%d-%d=%d", &a,&b,&c) = =3&&a-b==c) {sum++; }} printf ("%d\n", sum); return 0;}

Brother's Homework

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.