本人新学C,问题很多,现碰见这样的情况,请各位仁兄指点迷津: 1. #include "stdio.h" #include "conio.h" main() { double a,b,n; printf("\n-----------\n"); printf("please input a+b:\n"); scanf("%f+%f",&a,&b); printf("\nso a=%f b=%f ",a,b); n=f1(a,b); printf("\n n=%f",n); printf("\n-----------\n"); getch(); } double f1(double j,double k) { double z; z=j+k; return(z); } 结果编译不通过,提示错误:Type mismatch in redeclaration of 'f1',不解?!我尝试将所有数值变量都改为int,结果正常运行,为什么double不行呢?
2. #include "stdio.h" #include "conio.h" main() { double a,b,n; printf("\n-----------\n"); printf("please input a+b:\n"); scanf("%f+%f",&a,&b); printf("\nso a=%f b=%f ",a,b); n=a+b; printf("\n n=%f",n); printf("\n-----------\n"); getch(); }
结果运行时输入3+4,然后得到结果却是a=0.000000 b=0.000000 n=0.000000,不解