这个运行超时是什么原因?求助~
急 求高手解答!!自己运行就可以,测试就每次都说超时,什么原因啊? #include<stdio.h>
int item[200];
double price[10]={4.5,6.9,8.1,9.1,10.1,3.8,4.0,6.9,3.2,5.6};
double total=0;
int i;
void setMeal(int set)
{
int n=0;
int setItem[50];
double setTotal=0.000;
if(set==11)
{
printf("Choose 1 item from (1-5) :");
scanf("%d",&setItem[n]);
while(setItem[n]<1 || setItem[n]>5)
{
printf("Invalid item, please enter again\n");
scanf("%d",&setItem[n]);
}
setTotal+=price[setItem[n]-1];
n++;
printf("Choose 1 item from (6-8) :");
scanf("%d",&setItem[n]);
while(setItem[n]<6 || setItem[n]>8)
{
printf("Invalid item, please enter again\n");
scanf("%d",&setItem[n]);
}
setTotal+=price[setItem[n]-1];
n++;
printf("Choose 1 item from (9-10) :");
scanf("%d",&setItem[n]);
while(setItem[n]<9 || setItem[n]>10)
{
printf("Invalid item, please enter again\n");
scanf("%d",&setItem[n]);
}
setTotal+=price[setItem[n]-1];
n++;
setTotal=setTotal*0.98;
}
if(set==12)
{
printf("Choose 1 item from (1-5) :");
scanf("%d",&setItem[n]);
while(setItem[n]<1 || setItem[n]>5)
{
printf("Invalid item, please enter again\n");
scanf("%d",&setItem[n]);
}
setTotal+=price[setItem[n]-1];
n++;
printf("Choose 1 item from (9-10) :");
scanf("%d",&setItem[n]);
while(setItem[n]<9 || setItem[n]>10)
{
printf("Invalid item, please enter again\n");
scanf("%d",&setItem[n]);
}
setTotal+=price[setItem[n]-1];
n++;
setTotal=setTotal*0.99;
}
if(set==13)
{
printf("Choose 2 items from (1-5) :");
scanf("%d",&setItem[n]);
while(setItem[n]<1 || setItem[n]>5)
{
printf("Invalid item, please enter again\n");
scanf("%d",&setItem[n]);
}
setTotal+=price[setItem[n]-1];
n++;
scanf("%d",&setItem[n]);
while(setItem[n]<1 || setItem[n]>5)
{
printf("Invalid item, please enter again\n");
scanf("%d",&setItem[n]);
}
setTotal+=price[setItem[n]-1];
n++;
printf("Choose 1 item from (6-8) :");
scanf("%d",&setItem[n]);
while(setItem[n]<6 || setItem[n]>8)
{
printf("Invalid item, please enter again\n");
scanf("%d",&setItem[n]);
}
setTotal+=price[setItem[n]-1];
n++;
printf("Choose 2 items from (9-10) :");
scanf("%d",&setItem[n]);
while(setItem[n]<9 || setItem[n]>10)
{
printf("Invalid item, please enter again\n");
scanf("%d",&setItem[n]);
}
setTotal+=price[setItem[n]-1];
n++;
scanf("%d",&setItem[n]);
while(setItem[n]<9 || setItem[n]>10)
{
printf("Invalid item, please enter again\n");
scanf("%d",&setItem[n]);
}
setTotal+=price[setItem[n]-1];
n++;
setTotal=setTotal*0.95;
}
total+=setTotal;
}
void main()
{
float paid;
float change;
for(i=0;item[i-1]!=-1;i++)
{
scanf("%d",&item[i]);
setMeal(item[i]);
if(item[i]>13||item[i]<-1)
printf("Invalid item, please enter again\n");
if(item[i]==-1)
{
printf("Total: $%.1f\n",total); //show total price
printf("Pay:");
scanf("%f",&paid);
while(paid<total)
{
printf("Not enough payment, please enter again\n");
scanf("%f",&paid);
}
change=paid-total;
printf("Change: %.1f\n",change);
}
total+=price[item[i]-1];
}
}