文章

17

粉丝

133

获赞

4

访问

86.6k

头像
a与b得到c
P1821 复旦大学机试题
发布于2022年2月3日 20:34
阅读数 4.0k

#include<bits/stdc++.h>
using namespace std;
bool calculate(int a, int b, int c){
    if((a + b) == c) return true;
    else if((a - b) == c) return true;
    else if((a * b) == c) return true;
    
    //注意点在这里所以单写出来了
    else if((a / b) == c && (a%b==0)) return true;
    else return false;    
}
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int d = b, e = a;
    if(calculate(a,b,c) || calculate(d,e,c)) cout<<"YES";
    else cout<<"NO";
}

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发