104 lines
2.3 KiB
C
104 lines
2.3 KiB
C
#include <stdio.h>
|
|
#include <windows.h>
|
|
#define _USE_MATH_DEFINES
|
|
#include <math.h>
|
|
#define g 9.8f
|
|
|
|
void L2Z1(), L2Z2(), L2Z3(), L2Z4(), L2Z5(), L2Z6(), L2Z7();
|
|
|
|
int main2() {
|
|
system("chcp 1251");
|
|
|
|
//L2Z1();
|
|
//L2Z2();
|
|
//L2Z3();
|
|
//L2Z4();
|
|
//L2Z5();
|
|
//L2Z6();
|
|
L2Z7();
|
|
|
|
return 0;
|
|
}
|
|
|
|
void L2Z1() {
|
|
float h = 12, t = sqrt(2 * h / g);
|
|
printf("Êàìåíü óïàäåò çà %.2f ñåêóíä\n", t);
|
|
}
|
|
|
|
void L2Z2() {
|
|
float h, t;
|
|
printf("Ââåäèòå âûñîòó: ");
|
|
scanf_s("%f", &h);
|
|
t = sqrt(2 * h / g);
|
|
printf("Êàìåíü óïàäåò çà %.2f ñåêóíä", t);
|
|
}
|
|
|
|
void L2Z3() {
|
|
float S;
|
|
int cost_per_meter;
|
|
printf("Ââåäèòå ïëîùàäü è öåíó çà êâ.ì: ");
|
|
scanf_s("%f%d", &S, &cost_per_meter);
|
|
float price = S * cost_per_meter;
|
|
printf("%.2f", price);
|
|
}
|
|
|
|
void L2Z4() {
|
|
float S, percent = 0.5;
|
|
int cost_per_meter, salary;
|
|
printf("Ââåäèòå ïëîùàäü êâàðòèðû: ");
|
|
scanf_s("%f", &S);
|
|
printf("Ââåäèòå ñòîèìîñòü 1 êâ.ì: ");
|
|
scanf_s("%d", &cost_per_meter);
|
|
printf("Ââåäèòå çàðïëàòó: ");
|
|
scanf_s("%d", &salary);
|
|
printf("êâàðòèðà ïëîùàäüþ %f ïî öåíå %d çà êâ.ì ñòîèò %f\n", S, cost_per_meter, S * cost_per_meter);
|
|
float t = (S * cost_per_meter) / (salary * percent);
|
|
printf("ïðè çàðïëàòå %d íóæíî êîïèòü %1.2f ìåñ", salary, t);
|
|
}
|
|
|
|
void L2Z5() {
|
|
float V, R, H;
|
|
printf("íàõîæäåíèå îáúåìà øàðîâîãî ñåãìåíòà\n");
|
|
printf("Ââåäèòå ðàäèóñ øàðà: ");
|
|
scanf_s("%f", &R);
|
|
printf("Ââåäèòå âûñîòó øàðîâîãî ñåãìåíòà: ");
|
|
scanf_s("%f", &H);
|
|
if (H > 2 * R) H = 2 * R;
|
|
V = M_PI * pow(H, 2) * (R - H / 3);
|
|
printf("V øàðîâîãî ñåãìåíòà = %.2f", V);
|
|
}
|
|
|
|
void L2Z6() {
|
|
float V, a;
|
|
printf("Âû÷èñëåíèå ïóòè ïðè áàëëèñòè÷åñêîì äâèæåíèè\n");
|
|
printf("Ââåäèòå íà÷àëüíóþ ñêîðîòü: ");
|
|
scanf_s("%f", &V);
|
|
printf("Ââåäèòå óãîë â ãðàäóñàõ: ");
|
|
scanf_s("%f", &a);
|
|
float S = pow(V, 2) * sinf(2 * a * M_PI / 180) / g;
|
|
float H = pow(V * sinf(a * M_PI / 180), 2) / 2 / g;
|
|
printf("L = %.2f\n", S);
|
|
printf("H = %.2f\n\n", H);
|
|
}
|
|
|
|
void L2Z7() {
|
|
float A, r;
|
|
int n;
|
|
char currency[4];
|
|
|
|
printf("Ðàññ÷èòûâàåò ñóììó âûïëàò è ïåðåïëàòó ïî êðåäèòó\n");
|
|
|
|
printf("Ââåäèòå ñóììó çàéìà: ");
|
|
scanf_s("%f", &A);
|
|
printf("Ââåäèòå êîëè÷åñòâî ìåñÿöåâ: ");
|
|
scanf_s("%d", &n);
|
|
printf("Ââåäèòå ïðîöåíòíóþ ñòàâêó: ");
|
|
scanf_s("%f", &r);
|
|
printf("Ââåäèòå âàëþòó: ");
|
|
scanf_s("%s", currency, 4);
|
|
|
|
|
|
float S = A + ((A + A / n) * r * n / 2 / 100);
|
|
|
|
printf("Ñóììà âûïëàò %.2f %s\nÏåðåïëàòà %.2f %s\n\n", S, currency, S - A, currency);
|
|
} |