Created
April 19, 2025 10:28
-
-
Save Denkotleta221/21924641416683b3e92082d18441691d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <windows.h> // COORD HANDLE SetConsoleTextAttribute SetConsoleCursorPosition | |
#include <conio.h> // _getch | |
using namespace std; | |
//1) Task | |
void print_num(int num, int one = 1) { | |
if (one > num) { | |
cout << "FINISH!!!"; | |
} | |
else { | |
cout << one << "\n"; | |
print_num(num, one + 1); | |
} | |
} | |
//2) Task | |
void A_and_B(int a, int b) { | |
if (a >= b + 1) { | |
cout << "FINISH!!!"; | |
} | |
else { | |
cout << a << "\n"; | |
A_and_B(a + 1, b); | |
} | |
} | |
//3) Task | |
void two(int n) { | |
if(n == 1) | |
{ | |
cout << "YES"; | |
} | |
else if(n % 2 != 0 || n == 0) { | |
cout << "NO"; | |
} | |
else { | |
two(n / 2); | |
} | |
} | |
//4) Task | |
void sums(int n, int sum = 0) { | |
if (n == 0) { | |
cout << sum; | |
} | |
sums(n / 10, sum + (n % 10)); | |
} | |
//5) Task | |
void left(int n) { | |
if (n == 0) { | |
cout << "FINISH!!!"; | |
} | |
else { | |
cout << n % 10; | |
left(n / 10); | |
} | |
} | |
//6) Task | |
void right(int n) { | |
if (n < 10) { | |
cout << n << " "; | |
} | |
right(n / 10); | |
cout << n % 10 << " "; | |
} | |
int main() { | |
//1) Task | |
/*int n; | |
cin >> n; | |
print_num(n);*/ | |
//2) Task | |
/*int a; | |
int b; | |
cout << "Enter number A: "; | |
cin >> a; | |
cout << "Enter number B: "; | |
cin >> b; | |
A_and_B(a, b);*/ | |
//3) Task | |
/*int n; | |
cin >> n; | |
two(n);*/ | |
//4) Task | |
int n; | |
cin >> n; | |
sums(n); | |
//5)Task | |
/*int n; | |
cin >> n; | |
left(n);*/ | |
//6) Task | |
/*int n; | |
cin >> n; | |
right(n);*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment