90 lines
1.4 KiB
C++
90 lines
1.4 KiB
C++
#include<stdio.h>
|
|
#include <Windows.h>
|
|
|
|
void print1_10() {
|
|
int a = 1;
|
|
do {
|
|
printf("%d ", a);
|
|
a += 1;
|
|
} while (a <= 10);
|
|
}
|
|
|
|
void print10_1() {
|
|
int a = 10;
|
|
do {
|
|
printf("%d ", a);
|
|
a -= 1;
|
|
} while (a >= 1);
|
|
}
|
|
|
|
void print5() {
|
|
int a = 1;
|
|
int i = 1;
|
|
do {
|
|
printf("%d ", a);
|
|
a += 2;
|
|
i += 1;
|
|
} while (i <= 5);
|
|
}
|
|
void print100_10while() {
|
|
int a = 100;
|
|
while (a >= 10) {
|
|
printf("%d ", a);
|
|
a -= 10;
|
|
}
|
|
}
|
|
void print1000_100while() {
|
|
int a = 1000;
|
|
while (a >= 100) {
|
|
printf("%d ", a);
|
|
a -= 100;
|
|
}
|
|
}
|
|
void print1000_0while() {
|
|
int a = 1000;
|
|
while (a >= 0) {
|
|
printf("%d ", a);
|
|
a -= 6;
|
|
}
|
|
}
|
|
void main() {
|
|
SetConsoleCP(1251);
|
|
SetConsoleOutputCP(1251);
|
|
int n;
|
|
|
|
do {
|
|
printf("\n");
|
|
printf("\n");
|
|
printf("Âûáåðèòå íóæíóþ âàì îïåðàöèþ:\n");
|
|
printf("1: Âûâåñòè ÷èñëà îò 1 äî 10\n");
|
|
printf("2: Âûâåñòè ÷èñëà îò 10 äî 1\n");
|
|
printf("3: Âûâåñòè 5 ïåðâûõ ÷èñåë íà÷èíàÿ ñ 1\n");
|
|
printf("11: Âûâåñòè ÷èñëà 100 90 80 ... 10(÷åðåç WHILE)\n");
|
|
printf("12: Âûâåñòè ÷èñëà 1000 900 800 ... 100(÷åðåç WHILE)\n");
|
|
printf("20: Âûâåñòè ÷èñëà 1000 994 988 (÷åðåç WHILE)\n");
|
|
printf("\n");
|
|
printf("0: Âûéòè èç ïðîãðàììû\n");
|
|
scanf_s("%d", &n);
|
|
switch (n) {
|
|
case 1:
|
|
print1_10();
|
|
break;
|
|
case 2:
|
|
print10_1();
|
|
break;
|
|
case 3:
|
|
print5();
|
|
break;
|
|
case 11:
|
|
print100_10while();
|
|
break;
|
|
case 12:
|
|
print1000_100while();
|
|
break;
|
|
case 20:
|
|
print1000_0while();
|
|
break;
|
|
}
|
|
} while (n != 0);
|
|
}
|