Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void pow2(int n) {
- if (n >= 2) {
- if (n % 2 == 0) {
- n /= 2;
- cout << " " << n;
- pow2(n);
- }
- else cout << "\n no <3" << endl;
- if (n == 2) {
- cout << "\n yasss" << endl;
- }
- }
- }
- int t = 0;
- void digit_sum(int m) {
- t += m % 10;
- m /= 10;
- if (m > 9) {
- digit_sum(m);
- }
- else {
- cout << t + m;
- }
- }
- void reverse(int k) {
- cout << " " << k % 10;
- k /= 10;
- if (k > 9) {
- reverse(k);
- }
- else {
- cout << " " << k;
- }
- }
- int k = 0;
- void row(int j) {
- k++;
- if (j != 1) {
- for (int i = 0; i < k; i++) {
- cout << " " << k;
- if (i == j) exit(0);
- else if (i + 1 == k and k != j) {
- row(j);
- exit(0);
- }
- }
- }
- }
- int main() {
- int x;
- cout << "choose the program (1-4): " << endl;
- cin >> x;
- switch (x) {
- case 1:
- cout << "enter the number(pow2): " << endl;
- int n;
- cin >> n;
- pow2(n);
- break;
- case 2:
- cout << "\n enter the number(digit_sum): " << endl;
- int m;
- cin >> m;
- digit_sum(m);
- break;
- case 3:
- cout << "\n enter the number(reverse): " << endl;
- int k;
- cin >> k;
- reverse(k);
- break;
- case 4:
- cout << "\n enter the number(row): " << endl;
- int j;
- cin >> j;
- row(j);
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement