解题思路:很明显是个全排列,运用算法库的next_permutation即可;
注意事项:
参考代码:
#include<iostream> #include<algorithm> using namespace std; int main() { int s[10] = { 1,2,3,4,5,6,7,8,9 }; while (next_permutation(s, s + 9)) { int a = s[0] * 100 + s[1] * 10 + s[2]; int b = s[3] * 100 + s[4] * 10 + s[5]; int c = s[6] * 100 + s[7] * 10 + s[8]; if (b == 2 * a && c == 3 * a) cout << a << ' ' << b << ' ' << c << ' ' << endl; } return 0; }
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题8.8 (C++代码)浏览:545 |
逆反的01串 (C++代码)(依旧推荐switch)浏览:936 |
十->二进制转换 (C++代码)(零和负数需要特殊处理)浏览:1040 |
C语言训练-求矩阵的两对角线上的元素之和 (C语言代码)浏览:702 |
C语言训练-排序问题<2> (C++代码)(sort函数)浏览:1574 |
C语言程序设计教程(第三版)课后习题9.2 (C语言代码)浏览:687 |
不知道哪里错了浏览:1141 |
简单的a+b (C++语言代码)浏览:853 |
回文数(一) (C语言代码)浏览:729 |
成绩转换 (C语言代码)浏览:1005 |