塑身菜单
#include<stdio.h>int main()
{
int i,n,s=0;
struct menu
{
char name[1000];
int hot;
}a[15]={
{"Steamed Rice",31},
{"Scrambled Egg with Scallion",81},
{"Boiled Fish with Pickled Cabbage and Chili", 92},
{"Soybean Milk",92},
{"Steamed Jiaozi",119},
{"Scrambled Egg with Leek",128},
{"Steamed Bun Stuffed with Red Bean Paste",128},
{"Yu-Shiang Shredded Pork (Sauted with Spicy Garlic Sauce)",134},
{"Sauted Sliced Pork with Black Fungus",143},
{"Hot and Sour Rice Noodles",144},
{"Steamed Rice Rolls",196},
{"Sauted Sliced Pork with Pepper and Chili , Sichuan Style",231},
{"Cold Noodles Sichuan Style",260},
{"Fish Filets in Hot Chili Oil",239},
{"Kung Pao Chicken",313},
};
scanf("%d",&n);
for(i=0;i<15;i++)
{
s=s+a[i].hot;
if(s<=n)
{
printf("%s %d\n",a[i].name,a[i].hot);
}
else
{
break;
}
}
return 0;
}
我想问的是为什么要把Boiled Fish with Pickled Cabbage and Chili 92
Sauted Sliced Pork with Pepper and Chili , Sichuan Style 231
Cold Noodles Sichuan Style 260
Fish Filets in Hot Chili Oil 239
Steamed Rice Rolls 196
Kung Pao Chicken 313
Hot and Sour Rice Noodles 144
Soybean Milk 92
Steamed Rice 31
Scrambled Egg with Scallion 81
Steamed Jiaozi 119
Sauted Sliced Pork with Black Fungus 143
Scrambled Egg with Leek 128
Steamed Bun Stuffed with Red Bean Paste 128
Yu-Shiang Shredded Pork (Sauted with Spicy Garlic Sauce) 134 这些按数字从小到大的顺序排列之后运行的结果才是对的,而没有排列是答案是错误的,谢谢,新手求解