> 其他 >
编写程序完成计算正整数3829的各位数字平方和
人气:470 ℃ 时间:2020-02-03 15:21:38
解答
#include "stdio.h"
#include "stdlib.h"
int main(){
int x=3829;
int a1,a2,a3,a4;
int sum;
a1=x/1000;
a2=x/100%10;
a3=x/10%10;
a4=x%10;
sum=a1*a1+a2*a2+a3*a3+a4*a4;
printf("the sum is %d\n",sum);
return 0;
}
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版