11智能在线
新记
输入一个整数,编程求其绝对值(不能使用库函数)
如题所述
举报该文章
相关建议 推荐于2017-11-25
#include<stdio.h>
void main()
{
int x;
printf("please input x: ");
scanf("%d",&x);
if(x<0) x=-x;
printf("|x|=%d",x);
}
希望满意!!!望采纳!!!如果觉得好,望赞同!!!
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/28f7mfsp7.html
其他看法
第1个回答 2013-03-15
函数abs()可求绝对值,采用模板还可以通用,如下
int abs(int n){
return n<0?-n:n;
}
相似回答
大家正在搜
相关问题
怎么编写C程序:从键盘输入一个整数,求其绝对值并输出(提示:...
编程求一个数的绝对值(要求不用库函数fabs())
从键盘任意输入一个整数,不使用计算绝对值函数编程计算并输出该...
编写一个程序,从键盘上输入一个整数,并输出这个整数的绝对值。
入门c语言题:从键盘上输入任意一个整数,然后输出它的绝对值
c语言如何处理定义一个用于求整数绝对值函数?然后在主函数中调...
c语言要求求一个数的绝对值!!!过程!!!!
C++中,编写函数,输入一个整数,利用指针返回该数的绝对值。