为什么C语言中要输入”1,“才能运行下面的程序,而不是”1回车“
#include <stdio.h>int main()
{
int t1,t2;
float weight,cost,price;
printf("\n\n***********那欢迎进入中国民航国内运输规则行李托运费计算系统**********");
printf("\n请选择你的机票类型\n");
printf("\t 1成人票\n");
printf("\t 2儿童票\n");
printf("\t 3婴儿票\n");
printf("请按1,2或者3来选择你的机票类型 ");
scanf("%d\n",&t1);
printf("\n请选择机票的等级\n");
printf("\t 1.头等舱\n");
printf("\t 2.公务舱\n");
printf("\t 3.经济舱\n");
printf("\n请按1,2或者3来选择你的机票等级 ");
scanf("%d\n",&t2);
printf("\n请输入你的行李重量(kg):\n");
scanf("%f\n",&weight);
printf("\n请输入经济舱的机票价格:\n");
scanf("%f\n",&price);
if(t1==1&&t2==1&&weight<=40)
cost=0;
if(t1==1&&t2==1&&weight>40)
cost=(weight-40)*(price*0.015);
if(t1==1&&t2==2&&weight<=30)
cost=0;
if(t1==1&&t2==2&&weight>30)
cost=(weight-30)*(price*0.015);
if(t1==1&&t2==3&&weight<=20)
cost=0;
if(t1==1&&t2==3&&weight>20)
cost=(weight-20)*(price*0.015);
if(t1==2&&t2==1&&weight<=40)
cost=0;
if(t1==2&&t2==1&&weight>40)
cost=(weight-40)*(price*0.015);
if(t1==2&&t2==2&&weight<=30)
cost=0;
if(t1==2&&t2==2&&weight>30)
cost=(weight-30)*(price*0.015);
if(t1==2&&t2==3&&weight<=20)
cost=0;
if(t1==2&&t2==3&&weight>20)
cost=(weight-20)*(price*0.015);
if(t1==3)
cost=weight*(price*0.015);
printf("%f\n",cost);
[local]2[/local]
}
不知道为什么我运行程序的时候一定要按 1,才可以往下运行,而不是按1 回车运行,想不明白。而且运行之后还会直接跳过,出现乱码