#include <stdio.h>
int main()
{
int kase=0;
double r, w, l;
while(~scanf("%lf", &r) && r)
{
scanf("%lf%lf", &w, &l);
w /= 2;
l /= 2;
if(w * w + l * l <= r * r) printf("Pizza %d fits on the table.\n",++kase);
else printf("Pizza %d does not fit on the table.\n",++kase);
}
return 0;
int main()
{
int kase=0;
double r, w, l;
while(~scanf("%lf", &r) && r)
{
scanf("%lf%lf", &w, &l);
w /= 2;
l /= 2;
if(w * w + l * l <= r * r) printf("Pizza %d fits on the table.\n",++kase);
else printf("Pizza %d does not fit on the table.\n",++kase);
}
return 0;
}
心得:水题,本来看错题目想想还是做了吧。int型数比较大小时变成double,注意下
本文提供了一个简单的C语言程序示例,用于判断一个矩形比萨是否能完全放在圆形餐桌上。通过输入圆桌的半径及比萨的宽度和长度,程序会计算并判断比萨是否合适。

被折叠的 条评论
为什么被折叠?



