我想要输入购买装备刀,弹出相应的结果
都是无论输入什么都把什么结果弹了出来
#include<stdio.h>
int main(void)
{
int choice, i;
double price;
printf("需要购买哪些商品?\n");
printf("你现在的余额是100\n");
printf("[1]Select dao :price 15\n");//刀
printf("[2]Select jian :price 20\n");//剑
printf("[3]Select qiang :price 50\n");//枪
printf("[4]Select pao :price 100\n");//炮
printf("[5]Select quantao : price 10\n");//拳套
printf("[6]Select daodan : price 200\n");//导弹
printf("[0]exit\n");
for (i = 1; i <= 7; i++) {
printf("Enter chioice:");
scanf_s("%d", &choice);
if (choice == 0)
break;
switch (choice) {
case 1: price = 85; break;
case 2:price = 80; break;
case 3: price = 50; break;
case 4: price = 0; break;
case 5: price = 90; break;
case 6: price = -100; break;
default: price = 0; break;
}
printf("price=%0.lf\n", price);
}
printf("Thanks\n");
printf("现在外面充满了怪兽,少年拿起自己的武器进攻吧\n");
if (choice = 1) {
printf("你的刀是秦朝打造\n");
printf("时间过久,刀已经生锈\n");
printf("经过敌方强烈打击,刀已经损坏\n");
printf("你已经战败\n");
if (choice = 2) {
printf("你的剑是秦朝打造\n");
printf("时间过久,剑已经生锈\n");
printf("经过敌方强烈打击,刀已经损坏\n");
printf("你已经战败\n");
}
}
return 0;
}