Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int a, b;
- cin >> a >> b;
- for(int first = 1 ; first <= 9; first++){
- for(int second = 0; second <= 9; second++){
- for(int third = 0; third <= 9; third++){
- for(int fourth = 0; fourth <= 9; fourth++){
- for(int fifth = 0; fifth <= 9; fifth++){
- int number = 10000 * first + 1000 * second + 100 * third + 10 * fourth + fifth;
- if(number >= a && number <= b) {
- if(fifth + fourth == first + second){
- cout << number << " ";
- } else if(fifth + fourth < first + second){
- bool sum = fifth + fourth + third == first + second;
- if(sum){
- cout << number << " ";
- }
- } else if(fifth + fourth > first + second) {
- bool sum = fifth + fourth == first + second + third;
- if(sum){
- cout << number << " ";
- }
- }
- }
- }
- }
- }
- }
- }
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement