130 lines
1.7 KiB
C
130 lines
1.7 KiB
C
|
#include <stdio.h>
|
||
|
#include <stdbool.h>
|
||
|
#include <locale.h>
|
||
|
#include <math.h>
|
||
|
|
||
|
void L4Z1(), L4Z2(), L4Z3(), L4Z4(), L4Z5(), L4Z6(), L4Z7();
|
||
|
|
||
|
int main4() {
|
||
|
setlocale(LC_ALL, "RU");
|
||
|
|
||
|
//L4Z1();
|
||
|
//L4Z2();
|
||
|
//L4Z3();
|
||
|
//L4Z4();
|
||
|
//L4Z4();
|
||
|
//L4Z5();
|
||
|
//L4Z6();
|
||
|
//L4Z7();
|
||
|
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
void L4Z1() {
|
||
|
int n, i = 1;
|
||
|
|
||
|
printf("n = ");
|
||
|
scanf_s("%d", &n);
|
||
|
|
||
|
do {
|
||
|
printf("%d ", i);
|
||
|
i++;
|
||
|
} while (i <= n);
|
||
|
}
|
||
|
|
||
|
void L4Z2() {
|
||
|
int n, stepen = 1, i = 0;
|
||
|
printf("n = ");
|
||
|
scanf_s("%d", &n);
|
||
|
|
||
|
do {
|
||
|
printf("%d^%d = %d\n", n, i, stepen);
|
||
|
stepen *= n;
|
||
|
i++;
|
||
|
} while (i <= 5);
|
||
|
}
|
||
|
|
||
|
void L4Z3() {
|
||
|
float summa, percent;
|
||
|
int i = 0;
|
||
|
|
||
|
printf("summa = ");
|
||
|
scanf_s("%f", &summa);
|
||
|
|
||
|
printf("percent = ");
|
||
|
scanf_s("%f", &percent);
|
||
|
|
||
|
do {
|
||
|
printf("%2d year summa = %10.0f\n", i, summa);
|
||
|
summa *= (percent / 100 + 1);
|
||
|
i++;
|
||
|
} while (i <= 10);
|
||
|
}
|
||
|
|
||
|
void L4Z4() {
|
||
|
int n, i = 1;
|
||
|
scanf_s("%d", &n);
|
||
|
|
||
|
do {
|
||
|
printf("%d ", 2 * i);
|
||
|
i++;
|
||
|
} while (i <= n);
|
||
|
}
|
||
|
|
||
|
void L4Z5() {
|
||
|
int n, a, i = 1;
|
||
|
scanf_s("%d", &n);
|
||
|
scanf_s("%d", &a);
|
||
|
|
||
|
do {
|
||
|
printf("%d ", a * i);
|
||
|
i++;
|
||
|
} while (i <= n);
|
||
|
}
|
||
|
|
||
|
void L4Z6() {
|
||
|
int i = 2;
|
||
|
int n;
|
||
|
scanf_s("%d", &n);
|
||
|
|
||
|
do {
|
||
|
bool ok = true;
|
||
|
int del = 2;
|
||
|
|
||
|
while (del < ((int)sqrt(i)) + 1) {
|
||
|
if ((i % del) == 0) {
|
||
|
ok = false;
|
||
|
break;
|
||
|
}
|
||
|
del++;
|
||
|
}
|
||
|
|
||
|
/*for (int del = 2; del < ((int)sqrt(i)) + 1; del++) {
|
||
|
if ((i % del) == 0) {
|
||
|
ok = false;
|
||
|
break;
|
||
|
}
|
||
|
}*/
|
||
|
|
||
|
if (ok) {
|
||
|
printf("%d ", i);
|
||
|
n--;
|
||
|
}
|
||
|
i++;
|
||
|
} while (n > 0);
|
||
|
}
|
||
|
|
||
|
void L4Z7() {
|
||
|
int summ, transh, n;
|
||
|
float percent;
|
||
|
summ = 1000000, transh = 1000000, n = 3, percent = 18;
|
||
|
printf("summ, transh, n, percent");
|
||
|
scanf_s("%d%d%d%f", &summ, &transh, &n, &percent);
|
||
|
do {
|
||
|
summ = summ * (percent / 100 + 1) - transh;
|
||
|
n--;
|
||
|
} while (n > 0);
|
||
|
|
||
|
printf("%d", summ);
|
||
|
}
|