181 lines
2.6 KiB
C
181 lines
2.6 KiB
C
#include "func.h"
|
|
|
|
#ifdef Z1
|
|
void ot1do10(), ot10do1(), ot1_5odd(), ot1do100_10(), ot1000do100_100(), ot1000do0();
|
|
|
|
void Menu() {
|
|
int n;
|
|
|
|
do
|
|
{
|
|
printf("Âűáĺđčňĺ íóćíóţ âŕě îďĺđŕöčţ:\n");
|
|
printf("1) Âűâĺńňč ÷čńëŕ îň 1 äî 10\n");
|
|
printf("2) Âűâĺńňč ÷čńëŕ îň 10 äî 1\n");
|
|
printf("3) Âűâĺńňč 5 ďĺđâűé íĺ÷ĺňíűő ÷čńĺë ń 1\n");
|
|
printf("11) Âűâĺńňč 10 ÷čńĺë îň 10 äî 100\n");
|
|
printf("12) Âűâĺńňč 10 ÷čńĺë îň 1000 äî 100\n");
|
|
printf("20) Âűâĺńňč ÷čńĺëŕ îň 1000 äî 0 ń řŕăîě\n\n");
|
|
printf("99) Âűéňč čç ďđîăđŕěěű\n");
|
|
|
|
scanf_s("%d", &n);
|
|
|
|
switch (n)
|
|
{
|
|
case 1:
|
|
ot1do10();
|
|
break;
|
|
case 2:
|
|
ot10do1();
|
|
break;
|
|
case 3:
|
|
ot1_5odd();
|
|
break;
|
|
case 11:
|
|
ot1do100_10();
|
|
break;
|
|
case 12:
|
|
ot1000do100_100();
|
|
break;
|
|
case 20:
|
|
ot1000do0();
|
|
break;
|
|
}
|
|
|
|
} while (n != 99);
|
|
}
|
|
|
|
void twospace() {
|
|
printf("\n\n");
|
|
}
|
|
|
|
void ot1do10() {
|
|
int i = 1;
|
|
while (i <= 10) {
|
|
printf("%d ", i++);
|
|
}
|
|
twospace();
|
|
}
|
|
|
|
void ot10do1() {
|
|
int i = 10;
|
|
while (i >= 1) {
|
|
printf("%d ", i--);
|
|
}
|
|
twospace();
|
|
}
|
|
|
|
void ot1_5odd() {
|
|
int i = 0;
|
|
while (i <= 4) {
|
|
printf("%d ", 2 * i + 1);
|
|
i++;
|
|
}
|
|
twospace();
|
|
}
|
|
|
|
void ot1do100_10() {
|
|
int i = 1;
|
|
while (i <= 10) {
|
|
printf("%d ", i * 10);
|
|
i++;
|
|
}
|
|
twospace();
|
|
}
|
|
|
|
void ot1000do100_100() {
|
|
int i = 10;
|
|
while (i >= 1) {
|
|
printf("%d ", i * 100);
|
|
i--;
|
|
}
|
|
twospace();
|
|
}
|
|
|
|
void ot1000do0() {
|
|
int i = 1000;
|
|
int shag;
|
|
printf("ââĺäčňĺ řŕă:");
|
|
scanf_s("%d", &shag);
|
|
cycle:
|
|
printf("%d ", i);
|
|
i -= shag;
|
|
if (i > 0) goto cycle;
|
|
printf("%d", 0);
|
|
twospace();
|
|
}
|
|
#endif
|
|
|
|
#ifdef Z2
|
|
void pif(), MN(), triangle();
|
|
|
|
void Menu() {
|
|
int n;
|
|
|
|
do
|
|
{
|
|
printf("Âűáĺđčňĺ íóćíóţ âŕě îďĺđŕöčţ:\n");
|
|
printf("1) âűâĺńňč ňŕáëčöó ďčôŕăîđŕ\n");
|
|
printf("2) Âűâĺńňč ňŕáëčöó ń M ńňđîę č N ńňîëáöîâ\n");
|
|
printf("3) Âűâĺńňč ňđĺóăîëüíóţ ěŕňđčöó íĺďđŕâčëüíóţ\n\n");
|
|
printf("99) Âűéňč čç ďđîăđŕěěű\n");
|
|
|
|
scanf_s("%d", &n);
|
|
|
|
switch (n)
|
|
{
|
|
case 1:
|
|
pif();
|
|
break;
|
|
case 2:
|
|
MN();
|
|
break;
|
|
case 3:
|
|
triangle();
|
|
break;
|
|
}
|
|
|
|
} while (n != 99);
|
|
}
|
|
|
|
void MN() {
|
|
int M = 0, N = 0;
|
|
printf("ââĺäčňĺ M č N\n");
|
|
scanf_s("%d%d", &M, &N);
|
|
int i = 1;
|
|
while (i <= M) {
|
|
int j = 1;
|
|
while (j <= N) {
|
|
printf("%d%d ", i, j);
|
|
j++;
|
|
}
|
|
printf("\n\n");
|
|
i++;
|
|
}
|
|
}
|
|
|
|
void triangle() {
|
|
int i = 0;
|
|
do {
|
|
int j = 0;
|
|
while (j < i+1) {
|
|
printf("%d ", 5-j);
|
|
j++;
|
|
}
|
|
i++;
|
|
printf("\n");
|
|
} while (i < 5);
|
|
}
|
|
|
|
void pif() {
|
|
int i = 1;
|
|
while (i <= 10) {
|
|
int j = 1;
|
|
while (j <= 10) {
|
|
printf("%3d ", i * j);
|
|
j++;
|
|
}
|
|
printf("\n\n");
|
|
i++;
|
|
}
|
|
}
|
|
#endif |