Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int startNum, finalNum;
- cin >> startNum >> finalNum;
- for (int a = startNum / 1000; a <= finalNum / 1000; a++) {
- for (int b = startNum / 100 % 10; b <= finalNum / 100 % 10; b++) {
- for (int c = startNum / 10 % 10; c <= finalNum / 10 % 10; c++) {
- for (int d = startNum % 10; d <= finalNum % 10; d++) {
- if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1 && d % 2 == 1) {
- cout << a << b << c << d << " ";
- }
- }
- }
- }
- }
- return 0;
- }
- ИЛИ:
- #include <iostream>
- using namespace std;
- int main() {
- string startNum, finalNum;
- cin >> startNum >> finalNum;
- for (int a = startNum[0]; a <= finalNum[0]; a++) {
- for (int b = startNum[1]; b <= finalNum[1]; b++) {
- for (int c = startNum[2]; c <= finalNum[2]; c++) {
- for (int d = startNum[3]; d <= finalNum[3]; d++) {
- if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1 && d % 2 == 1) {
- cout << char(a) << char(b) << char(c) << char(d) << " ";
- }
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement