Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* In The Name of Allah */
- #include <algorithm>
- #include <bitset>
- #include <cassert>
- #include <cctype>
- #include <climits>
- #include <cmath>
- #include <complex>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <ctime>
- #include <deque>
- #include <fstream>
- #include <functional>
- #include <iomanip>
- #include <iostream>
- #include <limits>
- #include <list>
- #include <map>
- #include <numeric>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <string>
- #include <utility>
- #include <vector>
- using namespace std ;
- void rec1(int n){
- if(n < 1) return ;
- cout << n << " 1" << endl ;
- rec1(n - 1) ;
- cout << n << " 2" << endl ;
- }
- void rec2(int n){// print each of digit
- if(n < 10){
- cout << n << " " ;
- return ;
- }
- //cout << n % 10 << " " ;
- rec2(n / 10) ;
- cout << n % 10 << " " ;
- }
- int rec3(int n){// print sum of digit
- if(n < 10)
- return n ;
- return rec3(n / 10) + n % 10;
- }
- void rec4(int n4){// print all number that have only 4 , under 10000
- if(n4 > 10000) return ;
- cout << n4 << endl ;
- rec4(n4 * 10 + 4) ;
- }
- set < int > s ;
- void rec5(int n){// print all number that have only 4 and 7 , under 10000
- if(n > 10000) return ;
- //cout << n << endl ;
- s.insert(n) ;
- rec5(n * 10 + 4) ;
- rec5(n * 10 + 7) ;
- }
- int main(){
- //rec1(10) ; cout << endl ;// print somthing...
- //int n = 145639780 ;
- //rec2(n) ; cout << endl ;// print each of digit
- //cout << rec3(n) << endl ; // print sum of digit
- //rec4(4) ;// print all number that have only 4 , under 10000
- set < int > :: iterator it ;
- rec5(0) ;// print all number that have only 4 and 7 , under 10000
- for(set < int > :: iterator it = s.begin() ; it != s.end() ; it++)
- cout << *it << endl ;
- return 0 ;
- }
Add Comment
Please, Sign In to add comment