質問編集履歴
2
teisei
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,9 +82,9 @@
|
|
82
82
|
|
83
83
|
|
84
84
|
|
85
|
-
私のコードです。
|
85
|
+
私のコードです。
|
86
86
|
|
87
|
-
|
87
|
+
```C
|
88
88
|
|
89
89
|
#include <stdio.h>
|
90
90
|
|
@@ -174,6 +174,8 @@
|
|
174
174
|
|
175
175
|
}
|
176
176
|
|
177
|
+
```
|
178
|
+
|
177
179
|
|
178
180
|
|
179
181
|
```
|
1
teisei
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,4 +82,98 @@
|
|
82
82
|
|
83
83
|
|
84
84
|
|
85
|
-
私のコードです。
|
85
|
+
私のコードです。```C
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
#include <stdio.h>
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
double bmi_keisan(int height, int weight) /*このユーザー関数でBMIの計算を行う*/
|
94
|
+
|
95
|
+
{
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
double body_mass_index;
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
body_mass_index=(weight)/(height)*(height); /*BMIの求め方*/
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
return (body_mass_index); /*BMIの値を返す*/
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
int main(void)
|
114
|
+
|
115
|
+
{
|
116
|
+
|
117
|
+
int height;
|
118
|
+
|
119
|
+
int weight;
|
120
|
+
|
121
|
+
double bmi;
|
122
|
+
|
123
|
+
char* result;
|
124
|
+
|
125
|
+
do{
|
126
|
+
|
127
|
+
printf("身長 [cm] ? ");
|
128
|
+
|
129
|
+
scanf("%d",&height);
|
130
|
+
|
131
|
+
}while(height<0); /*身長は0よりもおおきい*/
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
do{
|
136
|
+
|
137
|
+
printf("体重 [kg] ? ");
|
138
|
+
|
139
|
+
scanf("%d",&weight);
|
140
|
+
|
141
|
+
}while(weight<0); /*体重は0よりもおおきい*/
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
printf("身長 = %d [cm]\n",height);
|
146
|
+
|
147
|
+
printf("体重 = %d [kg]\n",weight);
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
bmi = bmi_keisan(height,weight); /*ユーザー関数の呼び出し*/
|
152
|
+
|
153
|
+
if(bmi>=18.5 || bmi<25){ /*結果の判定*/
|
154
|
+
|
155
|
+
result = "標準型";
|
156
|
+
|
157
|
+
}else if(bmi>=25){
|
158
|
+
|
159
|
+
result = "肥満型";
|
160
|
+
|
161
|
+
}else{
|
162
|
+
|
163
|
+
result = "やせ型";
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
printf("BMI = %.1lf (%s) \n",bmi,result); /*結果の表示*/
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
return 0;
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
```
|