C/C++の宿題を片付けます 108代目 at TECH
[2ch|▼Menu]
514:デフォルトの名無しさん
08/06/03 13:42:50
>>508
#include <stdio.h>
#include <math.h>

#define PI 3.14159265358979323846

int check_side(int side) { return side > 0; }
int check_angle(int angle) { return 0 < angle && angle < 180; }

int main(void)
{
int side[2], angle, i;
for(i=0; i<2; i++) {
while(1) {
printf("辺%d(cm):", i+1);
scanf("%d", side + i);
if(check_side(side[i]))break;
printf("0より大きい整数を入力してください。\n");
}
}
while(1) {
printf("はさむ角(degree):");
scanf("%d", &angle);
if(check_angle(angle)) break;
printf("0より大きく180より小さい整数を入力してください。\n");
}
printf("<計算結果>\n面積(cm×cm):%f", side[0]*side[1]*sin(angle*PI/180)/2);
return 0;
}


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5230日前に更新/305 KB
担当:undef