题解 | #数字之和#
数字之和
https://www.nowcoder.com/practice/ae759916631f4711a90c4d4d9657f4b0
#include <cstdio> using namespace std; int sumnum(int n){ int sum=0; while (n>0){ sum=sum+n%10; n=n/10; } return sum; } int main(){ int arr; while (scanf("%d",&arr)!=EOF){ printf("%d %d\n", sumnum(arr), sumnum(arr*arr)); } }