217 lines
3.1 KiB
C
217 lines
3.1 KiB
C
#include <stdio.h>
|
|
#include <locale.h>
|
|
|
|
void L3Z1();
|
|
int L3Z2();
|
|
char* L3Z3();
|
|
int L3Z4();
|
|
char* L3Z5();
|
|
char* L3Z6();
|
|
char* L3Z7();
|
|
|
|
int main3() {
|
|
setlocale(LC_ALL, "RU");
|
|
|
|
//L3Z1();
|
|
//L3Z2();
|
|
//L3Z3();
|
|
//L3Z4();
|
|
//L3Z5();
|
|
//L3Z6();
|
|
//L3Z7();
|
|
|
|
return 0;
|
|
}
|
|
|
|
void L3Z1() {
|
|
float a, b;
|
|
printf("ââåäèòå ïåðâîå ÷èñëî: ");
|
|
scanf_s("%f", &a);
|
|
printf("ââåäèòå âòîðîå ÷èñëî: ");
|
|
scanf_s("%f", &b);
|
|
if (a == b) {
|
|
printf("Ââåäåííûå ÷èñëà ðàâíû");
|
|
}
|
|
else {
|
|
float max, min;
|
|
|
|
if (a > b) {
|
|
max = a;
|
|
min = b;
|
|
}
|
|
else {
|
|
max = b;
|
|
min = a;
|
|
}
|
|
printf("Íàèáîëüøåå ÷èñëî = %f\nÍàèìåíüøåå ÷èñëî = %f", max, min);
|
|
}
|
|
}
|
|
|
|
int L3Z2() {
|
|
int a, b, c;
|
|
printf("ââåäèòå 3 ÷èñëà: ");
|
|
scanf_s("%d %d %d", &a, &b, &c);
|
|
|
|
|
|
int max = a;
|
|
if (b > max) {
|
|
max = b;
|
|
}
|
|
if (c > max) {
|
|
max = c;
|
|
}
|
|
|
|
printf("max = %d", max);
|
|
return max;
|
|
}
|
|
|
|
char* L3Z3() {
|
|
int temperature;
|
|
char* ans = "";
|
|
printf("ââåäèòå òåìïåðàòóðó: ");
|
|
scanf_s("%d", &temperature);
|
|
if (temperature >= 18 && temperature < 22) {
|
|
ans = "õîëîäíî";
|
|
}
|
|
else if (temperature >= 22 && temperature < 26) {
|
|
ans = "òåëî";
|
|
}
|
|
else if (temperature >= 26) {
|
|
ans = "æàðêî";
|
|
}
|
|
|
|
printf("%s", ans);
|
|
return ans;
|
|
}
|
|
|
|
int L3Z4() {
|
|
int a[5];
|
|
printf("ââåäèòå 5 ÷èñåë: ");
|
|
for (int i = 0; i < 5; i++) {
|
|
scanf_s("%d", &a[i]);
|
|
}
|
|
|
|
int max = a[0];
|
|
for (int i = 1; i < 5; i++) {
|
|
if (a[i] > max) {
|
|
max = a[i];
|
|
}
|
|
}
|
|
printf("%d", max);
|
|
return max;
|
|
}
|
|
|
|
/*
|
|
tests:
|
|
input | output
|
|
1 | ìîðîç
|
|
2 | òåïëî
|
|
3 | æàðêî
|
|
4 | õîëîäíî
|
|
*/
|
|
char* L3Z5() {
|
|
char* ans = "";
|
|
int season;
|
|
|
|
printf("âûáåðèòå âðåìÿ ãîäà\n");
|
|
printf("1) çèìà\n");
|
|
printf("2) âåñíà\n");
|
|
printf("3) ëåòî\n");
|
|
printf("4) îñåíü\n");
|
|
|
|
scanf_s("%d", &season);
|
|
|
|
while (!(1 <= season && season <= 4)) {
|
|
printf("âûáåðèòå êîððåêòíîå âðåìÿ ãîäà\n");
|
|
printf("1) çèìà\n");
|
|
printf("2) âåñíà\n");
|
|
printf("3) ëåòî\n");
|
|
printf("4) îñåíü\n");
|
|
scanf_s("%d", &season);
|
|
}
|
|
|
|
if (season == 1) {
|
|
ans = "ìîðîç";
|
|
}
|
|
else if (season == 2) {
|
|
ans = "òåïëî";
|
|
}
|
|
else if (season == 3) {
|
|
ans = "æàðêî";
|
|
}
|
|
else {
|
|
ans = "õîëîäíî";
|
|
}
|
|
|
|
printf("%s", ans);
|
|
|
|
return ans;
|
|
|
|
}
|
|
|
|
/*
|
|
tests:
|
|
input | output
|
|
1 | äåøåâî
|
|
264000 | íîðìàëüíî
|
|
3567904 | óæàñ äîðîãî
|
|
*/
|
|
char* L3Z6() {
|
|
float price;
|
|
char* ans = "";
|
|
printf("öåíà íà ìèíèâýí = ");
|
|
scanf_s("%f", &price);
|
|
if (price <= 250000) {
|
|
ans = "äåøåâî";
|
|
}
|
|
else if (price > 250000 && price <= 700000) {
|
|
ans = "íîðìàëüíî";
|
|
}
|
|
else if (price > 700000 && price <= 1000000) {
|
|
ans = "äîðîãî";
|
|
}
|
|
else if (price > 1000000 && price <= 100000000) {
|
|
ans = "óæàñ äîðîãî";
|
|
}
|
|
printf("%s", ans);
|
|
|
|
return ans;
|
|
}
|
|
|
|
/*
|
|
tests:
|
|
input | output
|
|
1 | ìãíîâåííî
|
|
123 | áûñòðî
|
|
735 | íîðìàëüíî
|
|
9090 | î÷åíü ìåäëåííî
|
|
*/
|
|
char* L3Z7() {
|
|
float ms;
|
|
char* ans = "";
|
|
|
|
printf("ñêîðîñòü âûïîëíåíèÿ ïðîãðàììû = ");
|
|
scanf_s("%f", &ms);
|
|
|
|
if (ms <= 1) {
|
|
ans = "ìãíîâåííî";
|
|
}
|
|
else if (ms > 1 && ms <= 2) {
|
|
ans = "î÷åíü áûñòðî";
|
|
}
|
|
else if (ms > 2 && ms <= 100) {
|
|
ans = "áûñòðî";
|
|
}
|
|
else if (ms > 100 && ms <= 1000) {
|
|
ans = "íîðìàëüíî";
|
|
}
|
|
else if (ms > 1000 && ms <= 5000) {
|
|
ans = "ìåäëåííî";
|
|
}
|
|
else if (ms > 5000 && ms <= 10000) {
|
|
ans = "î÷åíü ìåäëåííî";
|
|
}
|
|
printf("%s", ans);
|
|
|
|
return ans;
|
|
} |