---
title: "九度1106 数字之和"
author: "piperzero"
date: "2013-01-27T05:45:00Z"
tags: []
slug: "1106"
draft: false
lastmod: "2013-03-06T20:51:42Z"
id: 1825056
url: "https://piperzero.iteye.com/blog/1825056"
---

```
/*********************************
 *    日期：2013-1-27
 *    作者：SJF0115
 *    题号: 九度1106
 *    题目：数字之和
 *    来源：http://ac.jobdu.com/problem.php?pid=1106
 *    结果：AC
 *    题意：
 *    总结：
**********************************/
#include<stdio.h>
#include<stdlib.h>
//各位置数字之和
int Sum(int n){
	int sum = 0;
	while(n){
		sum += n % 10;
		n = n / 10;
	}
	return sum;
}
 
int main()
{
	int n;
	//freopen("C:\\Users\\SJF\\Desktop\\acm.txt","r",stdin);  
	while(scanf("%d",&n)!=EOF && n != 0)
    {
		int pow = n * n;
		printf("%d ",Sum(n));
		printf("%d\n",Sum(pow));
	}
	return 0;
}
```