//paint.c -- 使用条件运算符
#include <stdio.h>
#define COVERAGE 350 //每罐油漆可刷的面积(单位:平方英尺)
int main(int argc, const char * argv[]) {
int sq_feet;
int cans;
printf("Enter the number of square feet to be painted:\n");
while (scanf("%d",&sq_feet)==1) {
cans=sq_feet/COVERAGE;
cans+=(sq_feet%COVERAGE==0)?0:1;
printf("Your need %d %s of paint.\n",cans,cans==1?"can":"cans");
printf("Enter the next value (q to quit).\n");
}
return 0;
}
paint.c
最新推荐文章于 2024-07-18 11:11:00 发布