이 스크립트를 실행하면 "최대 허풍 속도 # 1 입력 : "이라는 사례 1의 줄에 "34"를 입력하면 반환됩니다. "매듭 속의 바람 속도 : 25.6789" "허리케인 # 2의 최대 풍속을 입력하십시오 :"하지만 "Hurrican의 풍속이 올바르지 않습니다. 다시 시도하십시오."If/else 문이 while 루프 내에서 무시됩니다.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int x;
int year;
int tropical_storms;
int hurricanes;
int a=1;
int windspeed;
float knots;
float conversion=0.868976;
printf(" HEg v1.0 \n");
printf("0. Exit\n");
printf("1. Submit Hurricane Season Storm Information\n");
printf("2. Submit Storm Data\n");
printf("3. Print Hurricane Season Analysis\n");
printf("4. Print Storm Analysis\n");
printf("\n");
printf("Please Enter Selection: ");
scanf("%d", &x);
switch(x) {
case 0:
printf("Thank you for using HEg v1.0");
break;
case 1:
printf("Enter the year: ");
scanf("%d", &year);
printf("Enter the number of tropical storms in 2009: ");
scanf("%d", &tropical_storms);
printf("Enter the number of Hurricanes in 2009: ");
scanf("%d", &hurricanes);
while(a<=hurricanes){
printf("Enter the max windspeed of hurricane #%d: ", a);
scanf("%d", &windspeed);
a++;
if(windspeed>74){
knots=windspeed*conversion;
printf("Wind speed in knots: %.4f \n", knots);
}
else{
printf("Invalid Windspeed for Hurricane. Try again");
}
}
break;
case 2:
printf("Menu option not available in HEg v1.0");
break;
case 3:
printf("Menu option not available in HEg v1.0");
break;
case 4:
printf("Menu option not available in HEg v1.0");
break;
default:
printf("no");
break;
}
system("PAUSE>nul");
return 0;
}
왜'if' /'else' 문이 무시된다고 생각합니까? –
숙련 된 프로그래머로서 'if'진술이 무시되지 않는다는 것을 확신 할 수 있습니다. 실제로 일어난 일 * 및 *에 대해 * 귀하의 게시물을 업데이트하십시오. 또한이 동작을 유발하기 위해 입력 한 내용을 설명하십시오. –
"진술 내용의 내용"이 의미하는 바가 명확하지 않습니다. –