注册 登录
编程论坛 C++教室

求绝对值如何改啊?

呵呵肯 发布于 2013-10-22 14:20, 474 次点击
#include<stdio.h>
#include<math.h>


int main(void)
{
    double x,s;
    s = fabs( x);
    printf("%.2f\n",s);
    return 0;
}求绝对值如何改(结果保留两位小数)
4 回复
#2
在这里爬起2013-10-22 15:27
你要输入才会判断,用scanf语句
#3
qunxingw2013-10-22 16:01
照书启蒙
#4
RobinWang2013-10-23 17:53
回复 楼主 呵呵肯
#include<stdio.h>
#include<math.h>
void main()
{float x,s;
scanf("%f",&x);
s=fabs(x);
printf("%.2f\n",s);
}
#5
左手拉一只猫2013-10-27 20:10
#include<stdio.h>
#include<math.h>
void main(void)
{
    double x;
    scanf("%lf",&x);
    printf("%.2f\n",fabs(x));
}
少用一枚变量
1