C语言程序计算整数各位数字之和

 时间:2024-10-13 04:33:23

1、ubuntu 14.04 linux cgcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2

2、#include<stdio.h>#include<stdlib.h>int main(){ char integer[100]; int value = 0,temp_value = 0,sum = 0; gets(integer); value = atoi(integer); temp_value = value; while(value >= 1) { sum += value%10; value = value / 10; } printf("the integer is %d and the sum of decimal digits is %d \n",temp_value,sum); return 0;}

3、xxx@linux:~/code$ gcc -o sum sum.cxxx@linux:~/code$ ./sum123the integer is 123 and the sum of decimal digits is 6xxx@linux:~/code$ ./sum12345the integer is 12345 and the sum of decimal digits is 15

  • z=xy的图像怎么画
  • C语言逆序输出
  • 如何绘制校准曲线
  • 点到平面的投影怎么算
  • z=x^2+y^2图像怎么画
  • 热门搜索
    过敏性湿疹怎么治疗 电视投屏怎么设置 我的世界箭怎么做 qcy蓝牙耳机怎么样 u盾密码忘了怎么办 睑怎么读 存折密码忘了怎么办 血虚怎么办 怎么看显卡 手机空间不足怎么清理