习题合集各种有意义的题目
Posted phemiku
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了习题合集各种有意义的题目相关的知识,希望对你有一定的参考价值。
**1.
# include <iostream> # define LOCAL using namespace std; int main() /* # ifdef LOCAL freopen("C:\\Users\\Administrator\\Desktop\\新建文本文档.txt", "r", stdin); freopen("C:\\Users\\Administrator\\Desktop\\新建文本文档2.txt", "w", stdout); # endif */ int a, b, c, flag = 0, count = 0; while(cin >> a >> b >> c) count++; flag = 0; for(int i = 0; i < 34; i++) int num = 3 * i + a; if(num % 5 == b && num % 7 == c && num >0 && num < 100) cout << "Case " << count << ": " << num << endl; flag = 1; if(!flag) cout << "Case " << count << ": " << "NO answer!" << endl;
**2.习题2-6 排列( permutation)
用1, 2, 3, …, 9组成3个三位数abc, def和ghi, 每个数字恰好使用一次, 要
求abc: def: ghi= 1: 2: 3。 按照“abc def ghi”的格式输出所有解, 每行一个解。
# include <iostream> using namespace std; void Judge(int array[], int num) int a = num % 10, b = num / 10 % 10, c = num / 100; array[a]++; array[b]++; array[c]++; int main() for(int i = 100; i < 334; i++) int a[10] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; int abc = i * 1, def = i * 2, ghi = i * 3, j; Judge(a, abc); Judge(a, def); Judge(a, ghi); for(j = 1; j < 10; j++) if(a[j] != 1 || a[0] != 0) break; if(j == 10) cout << abc << ‘ ‘ << def << ‘ ‘ << ghi << endl;
以上是关于习题合集各种有意义的题目的主要内容,如果未能解决你的问题,请参考以下文章