Chinaunix首页 | 论坛 | 博客
  • 博客访问: 12378808
  • 博文数量: 1293
  • 博客积分: 13501
  • 博客等级: 上将
  • 技术积分: 17974
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-08 18:11
文章分类

全部博文(1293)

文章存档

2019年(1)

2018年(1)

2016年(118)

2015年(257)

2014年(128)

2013年(222)

2012年(229)

2011年(337)

分类: PHP

2011-07-11 21:23:00


一、程序代码

  1. # /* Name abs.c
  2. # * Author dyli
  3. # * date 20110711
  4. # * Description deepen understand the math
  5.    * function of abs()    
  6. # *
  7. # * */

  8. # /***abs()函数************************************************
  9. # * 函数功能: 取一个数的绝对值
  10. # * 函数原型:
  11. # * 返回值 : 绝对值
  12. # *
  13. # * 所需库 : math.h
  14. # * 备注 :
  15. # ****************************************************************/

  16. #include <stdio.h>
  17. #include <math.h>

  18. int main(void)
  19. {    
  20.     int nega_value = 0;
  21.     int posi_value = 0;
  22.     printf("please input a Negative number(fu shu)\n");
  23.     scanf("%d",&nega_value);

  24.     posi_value = abs(nega_value);
  25.     printf("---------->output the absolute value\n\---------->and it must be positive \n");
  26.     printf("look here %d \n",posi_value);
  27.     return 0;
  28. }


二、运行效果

  1. [root@localhost abc]# ls
  2. abs abs.c abs.c~ fopen.txt Makefile
  3. [root@localhost abc]# ./abs
  4. please input a Negative number(fu shu)
  5. -9632
  6. ---------->output the absolute value
  7. ---------->and it must be positive
  8. look here 9632
  9. [root@localhost abc]#





阅读(6800) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~