搜索
查看: 1410|回复: 4
打印 上一主题 下一主题

取小数函数的问题

[复制链接]
跳转到指定楼层
楼主
发表于 2013-3-3 16:30:37 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
5啊哈币
float tdec(float a);
#include <stdio.h>
#include <stdlib.h>
main()
{
float b,c;
scanf("%f",&b);
c=tint(b);
printf("%f",c);

system("pause");
return 0;
}
float tdec(float a);
{
while(a>1)
{ a--;
}
while(a<1)
{ a++;
}
return a;
}[code=Cpp width=740px][/code]
沙发
 楼主| 发表于 2013-3-10 13:27:03 | 显示全部楼层
改掉了,还不对[code=Cpp width=740px]float tdec(float a);
#include <stdio.h>
#include <stdlib.h>
main()
{
float b,c;
scanf("%f",&b);
c=tdec(b);
printf("%f",c);

system("pause");
return 0;
}
float tdec(float a);
{
while(a>1)
{ a--;
}
while(a<1)
{ a++;
}
return a;
}
[/code]
板凳
 楼主| 发表于 2013-3-17 14:54:15 | 显示全部楼层
谢谢,解决了
[code=AS3 width=740px]float tdec(float a);
#include <stdio.h>
#include <stdlib.h>
main()
{
float b,c;
scanf("%f",&b);
c=tdec(b);
printf("%g",c);

system("pause");
return 0;
}
float tdec(float a)
{ int a0=a;
while(a>1)
{ a--;
}
while(a<1)
{ a++;
}
if(a0>0)
return a-1;
if(a0<0)
return -(2-fabs(a));
}
[/code]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表