// 建一个判断函数,接受两个整形的变量,再通过循环按位判断相等与否,主体函数中调用被调函数,建立一个判断变量。#include <iostream> using namespace std; bool cmp (int x, int k) { while (k != 0) { int t1 = x % 10; int t2 = k % 10; if (t1 != t2) return false; x /= 10; k /= 10; } return true; } int main() { int n, m, flag = 1; cin >> n; while (n--) { cin >> m; for (int i = 1; i < 10; i++) { if (cmp(i * m * m, m)) { cout << i << ‘ ‘ << i * m * m << endl; flag = 0; break; } } if (flag) cout << "No" << endl; flag = 1; } return 0; }
原文地址:https://www.cnblogs.com/Hk456/p/10792547.html
时间: 2024-10-16 12:23:54