题解 | 纸牌游戏

纸牌游戏

https://www.nowcoder.com/practice/74f915e366094b19b94334de8b68e733

#include <stdio.h>
#include <stdbool.h>

bool compare(int a1, int b1, int a2, int b2) {
    if (a1 > b1 && a2 > b2)  return true;
    if (a1 == b1 && a2 > b2)  return true;
    if (a1 > b1 && a2 == b2)  return true;
    return false;
}
int main(void) {
    int t;
    scanf("%d", &t);

    while (t--) {
        int ans = 0;
        int a1, a2, b1, b2;
        scanf("%d%d%d%d", &a1, &a2, &b1, &b2);

        if (compare(a1, b1, a2, b2)) ans++;
        if (compare(a1, b2, a2, b1)) ans++;
        if (compare(a2, b1, a1, b2)) ans++;
        if (compare(a2, b2, a1, b1)) ans++;

        printf("%d\n", ans);
    }
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务