首页 > 其他分享 >输入任意一整数,求该整数各位数码之和

输入任意一整数,求该整数各位数码之和

时间:2022-09-26 23:25:00浏览次数:47  
标签:求该 10 sum n% 整数 数码 printf

#include <stdio.h>
main()
{
    int n,m,sum=0;
    scanf("%d",&n);
    m=n%10;
    sum=sum+m;
    printf("%d",m);
    n=n/10;
    while(n!=0)
    {
        m=n%10;
        sum=sum+m;
        printf("+%d",m);
        n=n/10;
         
    } 
    printf("=%d\n",sum);
}

 

标签:求该,10,sum,n%,整数,数码,printf
From: https://www.cnblogs.com/lachesism/p/16732937.html

相关文章