度分秒与十进制数之间的转换编码问题
#include<stdio.h>void main()
{
int m;
scanf("%d",&m);
if(m=0)
{
printf("请输入一个十进制的数a=");
float a,b,c=60,d,f=60,g;
scanf("%f",&a);
b=(int)(a);
c*=a-b;
d=(int)c;
f*=c-d;
printf("%.0f\'%.0f\'%.0f\"\n",b,d,f);
g=b+d/100+f/10000;
printf("%.4f\n",g);
}
else if
{
printf("请输入一个度数a=");
float a,b,c,d=60,f=3600,g;
scanf("%f",&a);
b=(int)a;
a=(a-b)*100;
c=(int)a;
a=(a-c)*100;
d=c/60;
f=a/3600;
g=b+d+f;
printf("g=%.4f\n",g);
}
}
error C2143: syntax error : missing ';' before 'type'
E:\text\2.c(10) : error C2065: 'a' : undeclared identifier
E:\text\2.c(11) : error C2065: 'b' : undeclared identifier
E:\text\2.c(12) : error C2065: 'c' : undeclared identifier
E:\text\2.c(13) : error C2065: 'd' : undeclared identifier
E:\text\2.c(14) : error C2065: 'f' : undeclared identifier
E:\text\2.c(16) : error C2065: 'g' : undeclared identifier
E:\text\2.c(20) : error C2059: syntax error : '{'
E:\text\2.c(22) : error C2143: syntax error : missing ';' before 'type'
E:\text\2.c(33) : error C2059: syntax error : '}'
执行 cl.exe 时出错.
2.exe - 1 error(s), 0 warning(s)