그래서 저는 방금 C로 쓰기 시작했고 제 수업을위한 첫 번째 프로젝트를 진행하고 있었고 계속 아래 오류 메시지가 나타납니다. 중괄호를 추가하고 제거하려고 시도했지만 문제를 파악할 수 없습니다.
암호:
#define hh 200
#define fc 150
#define pp 120
#define fchh 10
#define fcfc 20
#define fcpp 15
//this allows for easier multiplication for costs later on in the program
#include <stdio.h>
int main()
{
double ps, ga, hrs;
printf("Welcome to the Party Planning Program, select a party location:\n Holiday House: 1, Fun Center: 2, Party Plaza: 3\n Enter number of guests and number of hours:\n");
scanf("%lf %lf %lf", &ps, &ga, &hrs);
// here we assign the customer selections to the varibles//
if (hrs > 0 && hrs <11){
printf("hours valid, continue\n");
if(ps==1){
printf("Holiday House selected\n");
if(ga>0 && ga<201){
printf("number of ppl valid\n");
double max= 400+ ((hrs-1)*hh);
if(max<=1800){
printf("yay");
else{
printf("you need to cut it");
}
}
else{
printf("too many ppl");
}
}
else{
printf("waffle house");
}
}
else
printf("Incorrect selection, exiting program");
}
}
return 0;
}
에러 메시지:
hell.c: In function ‘main’:
hell.c:28:21: error: expected ‘}’ before ‘else’
else{
^
hell.c: At top level:
hell.c:44:1: error: expected identifier or ‘(’ before ‘}’ token
}
^
hell.c:45:1: error: expected identifier or ‘(’ before ‘return’
return 0;
^
hell.c:46:1: error: expected identifier or ‘(’ before ‘}’ token
}
^
#define hh 200
#define fc 150
#define pp 120
#define fchh 10
#define fcfc 20
#define fcpp 15
//this allows for easier multiplication for costs later on in the program
#include <stdio.h>
int main()
{
double ps, ga, hrs;
printf("Welcome to the Party Planning Program, select a party location:\n Holiday House: 1, Fun Center: 2, Party Plaza: 3\n Enter number of guests and number of hours:\n");
scanf("%lf %lf %lf", &ps, &ga, &hrs);
// here we assign the customer selections to the varibles//
if (hrs > 0 && hrs <11){
printf("hours valid, continue\n");
if(ps==1){
printf("Holiday House selected\n");
if(ga>0 && ga<201){
printf("number of ppl valid\n");
double max= 400+ ((hrs-1)*hh);
if(max<=1800){
printf("yay");
} else{
printf("you need to cut it");
}
} else {
printf("too many ppl");
}
} else{
printf("waffle house");
}
} else {
printf("Incorrect selection, exiting program");
}
return 0;
}
이걸로 해봐
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다