Guest User

Untitled

a guest
Oct 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1.  
  2. /* In The Name of Allah */
  3.  
  4. #include <algorithm>
  5. #include <bitset>
  6. #include <cassert>
  7. #include <cctype>
  8. #include <climits>
  9. #include <cmath>
  10. #include <complex>
  11. #include <cstdio>
  12. #include <cstdlib>
  13. #include <cstring>
  14. #include <ctime>
  15. #include <deque>
  16. #include <fstream>
  17. #include <functional>
  18. #include <iomanip>
  19. #include <iostream>
  20. #include <limits>
  21. #include <list>
  22. #include <map>
  23. #include <numeric>
  24. #include <queue>
  25. #include <set>
  26. #include <sstream>
  27. #include <stack>
  28. #include <string>
  29. #include <utility>
  30. #include <vector>
  31.  
  32. using namespace std ;
  33.  
  34. void rec1(int n){
  35. if(n < 1) return ;
  36. cout << n << " 1" << endl ;
  37. rec1(n - 1) ;
  38. cout << n << " 2" << endl ;
  39. }
  40.  
  41. void rec2(int n){// print each of digit
  42. if(n < 10){
  43. cout << n << " " ;
  44. return ;
  45. }
  46. //cout << n % 10 << " " ;
  47. rec2(n / 10) ;
  48. cout << n % 10 << " " ;
  49. }
  50. int rec3(int n){// print sum of digit
  51. if(n < 10)
  52. return n ;
  53. return rec3(n / 10) + n % 10;
  54. }
  55. void rec4(int n4){// print all number that have only 4 , under 10000
  56. if(n4 > 10000) return ;
  57. cout << n4 << endl ;
  58. rec4(n4 * 10 + 4) ;
  59. }
  60. set < int > s ;
  61. void rec5(int n){// print all number that have only 4 and 7 , under 10000
  62. if(n > 10000) return ;
  63. //cout << n << endl ;
  64. s.insert(n) ;
  65. rec5(n * 10 + 4) ;
  66. rec5(n * 10 + 7) ;
  67. }
  68. int main(){
  69. //rec1(10) ; cout << endl ;// print somthing...
  70.  
  71. //int n = 145639780 ;
  72. //rec2(n) ; cout << endl ;// print each of digit
  73. //cout << rec3(n) << endl ; // print sum of digit
  74.  
  75. //rec4(4) ;// print all number that have only 4 , under 10000
  76. set < int > :: iterator it ;
  77. rec5(0) ;// print all number that have only 4 and 7 , under 10000
  78. for(set < int > :: iterator it = s.begin() ; it != s.end() ; it++)
  79. cout << *it << endl ;
  80. return 0 ;
  81. }
Add Comment
Please, Sign In to add comment