cjweffort

博客园 首页 联系 订阅 管理

http://ac.jobdu.com/problem.php?cid=1040&pid=40

题目描述:
打印所有不超过n(n<256)的,其平方具有对称性质的数。
如11*11=121
输入:

无任何输入数据

输出:
输出具有题目要求的性质的数。如果输出数据不止一组,各组数据之间以回车隔开。
样例输入:

样例输出:

// 题目41:对称平方数.cpp: 主项目文件。

#include "stdafx.h"
#include <cstdio>

bool isDui(int n)
{
	int res=n*n;
	int arrA[11];
	int cntA=0;
	while(res)
	{
		arrA[cntA++]=res%10;
		res/=10;
	}
	for(int i=0,j=cntA-1;i<=j;i++,j--)
		if(arrA[i]!=arrA[j])
			return false;
	return true;
}

int main()
{
	freopen("F:\\output.txt","w",stdout);
    for(int i=0;i<256;i++)
		if(isDui(i))
			printf("%d\n",i);
    return 0;
}


posted on 2013-03-05 11:35  cjweffort  阅读(206)  评论(0编辑  收藏  举报