蓝桥——六位排他平方数
作者:互联网
题目:
代码:
// test.cpp: 定义控制台应用程序的入口点。 // #include "stdafx.h" #include<iostream> #include<sstream> #include <type_traits> using namespace std; //判断string是否每个都不同 bool judgeSelfNoSame(string s) { long long i, j; for ( i = 0; i < s.length();i++) for (j = 0; j < s.length(); j++) { if (s[i] == s[j] && i != j) return false; } return true; } bool judge2NoSame(string a, string b) { long long i, j; for (i = 0; i < a.length(); i++) for (j = 0;j < b.length(); j++) { if (b[j] == a[i]) return false; } return true; } void l2s(long long a, string &s) { stringstream ss; ss << a; ss >> s; } int main() { string s; string pfs; for (long long i = 123456; i < 1000000; i++) { l2s(i, s); if (judgeSelfNoSame(s)) { l2s(i*i, pfs); if (judge2NoSame(s, pfs))cout << i << endl; } } return 0; }
标签:平方,return,string,六位,long,蓝桥,++,length,include 来源: https://www.cnblogs.com/ZengWeiHao/p/10467765.html