example/LABA_9/Source.cpp

72 lines
909 B
C++
Raw Normal View History

2024-11-19 16:17:52 +04:00
#include <stdio.h>
#include <Windows.h>
void print1to10(){
int x = 1;
do {
printf("%d", x);
x++;
} while (x <= 10);
}
void print10to1() {
int x = 10;
do {
printf("%d", x);
x-=1;
} while (x >= 1);
}
void print5nechet() {
int x = 1, k = 1;
do {
printf("%d", x);
x += 2;
k++;
}while (k != 5);
}
void print100to10() {
int x = 100;
while (x >= 10) {
printf("%d", x);
x -= 10;
}
}
void print1000to100() {
int x = 1000;
while (x >= 100) {
printf("%d", x);
x -= 100;
}
}
void print1000to2() {
int x = 1000;
while (x >= 2) {
printf("%d", x);
x -= 2;
}
}
int main() {
int n = 0;
scanf_s("%d", &n);
switch (n) {
case 1:
print1to10();
break;
case 2:
print10to1();
break;
case 3:
print5nechet();
break;
case 11:
print100to10();
break;
case 12:
print1000to100();
break;
case 20:
print1000to2();
break;
default:
break; (n != 0);
}
return 0;
}