Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. void f(long n)
  6. {
  7. if (n!=0)
  8. {
  9. if (n%2==0)
  10. {
  11. cout<<n%10;
  12. }
  13. f(n/10);
  14. if (n%2!=0)
  15. {
  16. cout<<n%10;
  17. }
  18. }
  19. else
  20. {
  21. cout<<endl;
  22. }
  23. }
  24. int main()
  25. {long n;
  26. cout <<"N=";cin>>n;
  27. f(n);
  28. return 0;
  29. }
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. #include <iostream>
  41.  
  42. using namespace std;
  43. void f (int b)
  44. {
  45. if(3<=b)
  46. {
  47. f(b-2);
  48. cout<<'*';
  49. }
  50. else
  51. {
  52. cout<<b;
  53. }
  54. }
  55. int main()
  56. {int b;
  57. cout <<"B=";cin>>b;
  58. f(b);
  59. return 0;
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. #include <iostream>
  69.  
  70. using namespace std;
  71. int f (int n)
  72. {
  73. int c;
  74. if (n!=0)
  75. {
  76. if (n%2==1)
  77. {
  78. c=1+f(n/2);
  79. }
  80. else
  81. {
  82. c=f(n/2);
  83. }
  84. cout<<n%2;
  85. return c;
  86. }
  87. else
  88. {
  89. return 0;
  90. }
  91. }
  92. int main()
  93. {int n;
  94. cout<<"N=";cin>>n;
  95. cout <<f(n);
  96. return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement