C程序出错,帮我看看哪里错了?
main()
{
double m,sum=0,r,y=0;
char n,c;
printf("please enter the money:\n");
scanf("%.0f",&m);
printf("please choose the time:\n");
printf("1.5year 2.3year 3.2year 4.1year 5.6months 6.3month\n");
scanf("%s",&n);
switch(n)
{
case '1':
y=5;
break;
case '2':
y=3;
break;
case '3':
y=2;
break;
case '4':
y=1;
break;
case '5':
y=0.5;
break;
case '6':
y=0.25;
break;
default:
break;
}
printf("please choose the rate:\n");
printf("1. 4.75%% 2. 4.25%% 3. 3.75%% 4. 3.00%% 5. 2.8%% 6. 2.60%% 7.selfset");
scanf("%s",&c);
switch(c)
{
case '1':
sum=m*(1+0.0475*y);
break;
case '2':
sum=m*(1+4.25/100*y);
break;
case '3':
sum=m*(1+3.75/100*y);
break;
case '4':
sum=m*(1+3/100*y);
break;
case '5':
sum=m*(1+2.8/100*y);
break;
case '6':
sum=m*(1+2.6/100*y);
break;
case '7':
printf("please enter the rate:");
scanf("%f",&r);
sum=m*(1+r/100*y);
break;
default:
break;
}
printf("you will get :%.2f",sum);
putchar(getchar());
while(getchar()!='\n')
continue;
getchar();
void main()
{
double m,sum=0,r,y=0;
char n,c;
printf("please enter the money:\n");
/凳肆/ scanf("%.0f",&m);
scanf("%lf",&m);
fflush(stdin); // 清空输入缓冲区
printf("please choose the time:\n");
printf("1.5year 2.3year 3.2year 4.1year 5.6months 6.3month\n");
scanf("%s",&n);
fflush(stdin);
switch(n)
{
case '1':
y=5;
break;
case '2':
y=3;
break;
case '3':
y=2;
break;
case '4':
y=1;
break;
case '兄粗此5':
y=0.5;
break;
case '6':
y=0.25;
break;
default:
break;
}
printf("please choose the rate:\n");
printf("1. 4.75%% 2. 4.25%% 3. 3.75%% 4. 3.00%% 5. 2.8%% 6. 2.60%% 7.selfset\n");
scanf("%s",&c);
fflush(stdin);
switch(c)
{
case '1':
sum=m*(1+0.0475*y);
break;
case '2':
sum=m*(1+4.25/100*y);
break;
case '3':
sum=m*(1+3.75/100*y);
break;
case '4':
sum=m*(1+3/100*y);
break;
case '5':
sum=m*(1+2.8/100*y);
break;
case '6':
sum=m*(1+2.6/100*y);
break;
case '7':
printf("please enter the rate:");
scanf("%f",&r);
fflush(stdin);
sum=m*(1+r/100*y);
break;
default:
break;
}
printf("you will get :%.2f",sum);
putchar(getchar());
while(getchar()!='羡迅\n')
continue;
getchar();
}
独到的
输入输出函数未定义,在最前面加个#include <stdio.h>
最后一行少个大括号。
修改如下:
#include <stdio.h>
void main()
{
double m,sum=0,r,y=0;
char n,c;
printf("please enter the money:\n");
scanf("%.0f",&m);
printf("please choose the time:\n");
printf("1.5year 2.3year 3.2year 4.1year 5.6months 6.3month\n");
scanf("%s",&n);
switch(n)
{
case '1':
y=5;
break;
case '2':
y=3;
break;
case '3':
y=2;
break;
case '4':
y=1;
break;
case '5':
y=0.5;
break;
case '芦丛6':
y=0.25;
break;
default:
break;
}
printf("please choose the rate:\n");
printf("1. 4.75%% 2. 4.25%% 3. 3.75%% 4. 3.00%% 5. 2.8%% 6. 2.60%% 7.selfset");
scanf("%s",&c);
switch(c)
{
case '1':
sum=m*(1+0.0475*y);
break;
case '2':
sum=m*(1+4.25/100*y);
break;
case '3':
sum=m*(1+3.75/100*y);
break;
case '4':
sum=m*(1+3/100*y);
break;
case '悔派5':
sum=m*(1+2.8/100*y);
break;
case '6':
sum=m*(1+2.6/100*y);
break;
case '7':
printf("please enter the rate:"碧哗贺);
scanf("%f",&r);
sum=m*(1+r/100*y);
break;
default:
break;
}
printf("you will get :%.2f",sum);
putchar(getchar());
while(getchar()!='\n')
continue;
getchar();
}
#include<stdio.h>
main()
{
float m,sum=0,r,y=0;
int c;
printf("please enter the money:\n");
scanf("%f",&m);
printf("please choose the time:\n");
printf("1.5 year 2.3 year 3.2 year 4.1 year 5.6 months 6.3 month\n");
scanf("%d",&c);
switch(c)
{
case 1:
y=5;
break;
case 2:
y=3;
break;
case 3:
y=2;
break;
case 4:
y=1;
break;
case 5:
y=0.5;
break;
case 6:
y=0.25;
break;
default:
break;
}
printf("please choose the rate:\n");
printf("1. 4.75%% 2. 4.25%% 3. 3.75%% 4. 3.00%% 5. 2.8%% 6. 2.60%% 7.selfset\n");
scanf("%d",&c);
switch(c)
{
case 1:
sum=m*(1+0.0475*y);
break;
case 2:
sum=m*(1+4.25/100*y);
break;
case 3:
sum=m*(1+3.75/100*y);
break;
case 4:
sum=m*(1+3/100*y);
break;
case 5:
sum=m*(1+2.8/100*y);
break;
case 6:
sum=m*(1+2.6/100*y);
break;
case 7:
printf("please enter the rate:");
scanf("%f",&r);
sum=m*(1+r/100*y);
break;
default:
break;
}
printf("you will get :%.2f",sum);
putchar(getchar());
while(getchar()!='\n')
continue;
}
#include<stdio.h>//这里缺少了灶游头文件
main()
{
double m,sum=0,r,y=0;
char n,c;
printf("please enter the money:\n");
scanf("%.0f",&m);
printf("please choose the time:\n");
printf("1.5year 2.3year 3.2year 4.1year 5.6months 6.3month\亩档n");
scanf("%s",&n);
switch(n)
{
case '1':
y=5;
break;
case '2':
y=3;
break;
case '3':
y=2;
break;
case '4':
y=1;
break;
case '5':
y=0.5;
break;
case '6':
y=0.25;
break;
default:
break;
}
printf("please choose the rate:\n");
printf("1. 4.75%% 2. 4.25%% 3. 3.75%% 4. 3.00%% 5. 2.8%% 6. 2.60%% 7.selfset");
scanf("%s",&c);
switch(c)
{
case '1':
sum=m*(1+0.0475*y);
break;
case '2':
sum=m*(1+4.25/100*y);
break;
case '3':
sum=m*(1+3.75/100*y);
break;
case '4':
sum=m*(1+3/100*y);
break;
case '5':
sum=m*(1+2.8/100*y);
break;
case '6':
sum=m*(1+2.6/100*y);
break;
case '7':
printf("please enter the rate:"隐耐销);
scanf("%f",&r);
sum=m*(1+r/100*y);
break;
default:
break;
}
printf("you will get :%.2f",sum);
putchar(getchar());
while(getchar()!='\n')
continue;
getchar();}//这里少了大括号