#include<bits/stdc++.h> using namespace std; int main(){ string s,s1,s2; for(int i=1000;i<10000;i++){ s1.clear();//循环开头记得清空字符串 s2.clear(); s = to_string(i);//把 int 转换成 string s1.push_back(s[0]); s1.push_back(s[1]); s2.push_back(s[2]); s2.push_back(s[3]); if((stoi(s1)+stoi(s2))*(stoi(s1)+stoi(s2))==i){//stoi()把 string 转换成 int cout << i << " "; } } return 0; }
0.0分
0 人评分
C语言训练-求函数值 (C语言代码)浏览:938 |
字符串比较 (C语言代码)答案错误????浏览:597 |
大神老白 (C语言代码)浏览:645 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:661 |
【蟠桃记】 (C语言代码)浏览:664 |
WU-拆分位数 (C++代码)浏览:785 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:621 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)from DQM浏览:670 |
C二级辅导-计负均正 (C语言代码)浏览:482 |
小O的数字 (C语言代码)浏览:1411 |