P5712 刷題記錄

題面地址:P5712
注意到蘋果數量有可能小於1,故分支邏輯判斷語句要寫成(quantity <= 1)的形式。

完整代碼如下:(C++)

#include <stdio.h>

int main()
{
    int quantity;
    scanf("%d", &quantity);
    if(quantity <= 1)
        printf("Today, I ate %d apple.", quantity);
    if(quantity > 1) {
        printf("Today, I ate %d apples.", quantity);
    }

    return 0;
}
原文地址:https://www.cnblogs.com/kozumi/p/12772976.html