C/C++の宿題を片付けます 119代目
■ このスレッドは過去ログ倉庫に格納されています
0408デフォルトの名無しさん
2008/12/09(火) 17:25:21#include <stdio.h>
double area(double w, double h){
return (w>0?w:0)*(h>0?h:0);
}
int main(){
double width1, height1, width2, height2;;
printf("Input 4 numbers: ");
scanf("%lf %lf %lf %lf",&width1, &height1, &width2, &height2);
if(area(width1, height1) > area(width2, height2))
printf("rectangle 1 is larger than rectangle 2.\n");
else if(area(width1, height1) < area(width2, height2))
printf("rectangle 2 is larger than rectangle 1.\n");
else
printf("Same rectangeles.\n");
return 0;
}
>>407だと、
>ただし,w 又はh が負の値の場合は,長方形の面積はゼロとすることにする。
が満たされないと思う。
■ このスレッドは過去ログ倉庫に格納されています