这真的很怪,在帮忙看看.谢谢!!
能不能在帮我看看..以下两个程序.结果会有什么不同...能说一下为什么吗???其实两个程序就是差在..一个是用int 一个是用float,但出来的结果却不是预期的..真的很怪,谢指教,谢谢.
程序1;
#include<stdio.h>
int caculateChareg(int);
int caculateChareg(int n,int time,int time1)
{
int mony1=n;
if(time1<=time-3){
time1++;
caculateChareg(n+1,time,time1);
}
else
printf(" %d",mony1);
}
main()
{
int ca,mony,t1=0,m=2;
scanf("%d",&ca);
if (ca<=3){
mony=2;
printf("%d",mony);
}
else
caculateChareg(m,ca,t1);
}
程序2;
#include<stdio.h>
float caculateChareg(float);
float caculateChareg(float n,float time,float time1)
{
float mony1=n;
if(time1<=time-3){
time1++;
caculateChareg(n+1,time,time1);
}
else
printf(" %f",mony1);
}
main()
{
float ca,mony,t1=0,m=2;
scanf("%f",&ca);
if (ca<=3){
mony=2;
printf("%f",mony);
}
else
caculateChareg(m,ca,t1);
}