VC6.0计算结果和想的不一样
如图我的想法计算结果应该uu=xx+u等于30.00呀,请高手帮忙改下程序~
#include<conio.h>
#include<stdio.h>
#include<math.h>
float xx,zz,u,w,uu,ww;
static char str;
void func3();
void func4();
int main()
{
printf("X\n");
scanf("%f",&xx);
printf("Z\n");
scanf("%f",&zz);
scanf("%s",str);
if ( str == 'U' ) {
func3();
}
else if ( str == 'W' ) {
func4();
}
getch();
}
void func3 ()
{
uu=xx+u;
ww=zz+w;
scanf("%f",&u);
printf("X%.2f\n",uu);
}
void func4 ()
{
uu=xx+u;
ww=zz+w;
scanf("%f",&w);
printf("Z%.2f\n",ww);
} 拿点鱼币 那你输入的数值控制一下就可以了。。 自己解决了!
#include<conio.h>
#include<stdio.h>
#include<math.h>
float xx,zz,u,w,uu,ww;
static char str;
void func3();
void func4();
int main()
{
printf("X\n");
scanf("%f",&xx);
printf("Z\n");
scanf("%f",&zz);
scanf("%s",&str);
if ( str == 'U' ) {
func3();
}
else if ( str == 'W' ) {
func4();
}
getch();
}
void func3 ()
{
scanf("%f",&u);
uu=xx+u;
ww=zz+w;
printf("X%.2f\n",uu);
}
void func4 ()
{
scanf("%f",&w);
uu=xx+u;
ww=zz+w;
printf("Z%.2f\n",ww);
}
页:
[1]