海洋之心


私信TA

用户名:wanggongsheng

访问量:122679

签 名:

等  级
排  名 17
经  验 20527
参赛次数 3
文章发表 163
年  龄 26
在职情况 学生
学  校
专  业 计算机技术

  自我简介:

读研ing,平时不登录dotcpp

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int stoint(char s[])
{
    if(strlen(s)==1) return *s-'0';
    if(strlen(s)==2) return (*s-'0')*10+*(s+1)-'0';
    if(strlen(s)==3) return (*s-'0')*100+(*(s+1)-'0')*10+(*(s+2)-'0');
}
int fac(int a,char ch,int b,char s[])
{
    int c;
    if(s[0]=='?') return 0;
    c=stoint(s);
    if(ch=='+') return a+b==c;
    else return a-b==c;
}
int main(void)
{
    int sum=0,a,b;
    char ch,s[4];
    while(scanf("%d%c%d=%s",&a,&ch,&b,s)!=EOF)
        sum+=fac(a,ch,b,s);
    cout << sum << endl;
    return 0;
}

解题思路:





注意事项:





参考代码:

 

0.0分

2 人评分

  评论区