Lab4/lab/lab3.c

217 lines
3.1 KiB
C
Raw Permalink Normal View History

2024-11-19 22:09:32 +04:00
#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("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>: ");
scanf_s("%f", &a);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>: ");
scanf_s("%f", &b);
if (a == b) {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>");
}
else {
float max, min;
if (a > b) {
max = a;
min = b;
}
else {
max = b;
min = a;
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> = %f\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> = %f", max, min);
}
}
int L3Z2() {
int a, b, c;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3 <20><><EFBFBD><EFBFBD><EFBFBD>: ");
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("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ");
scanf_s("%d", &temperature);
if (temperature >= 18 && temperature < 22) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if (temperature >= 22 && temperature < 26) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if (temperature >= 26) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
printf("%s", ans);
return ans;
}
int L3Z4() {
int a[5];
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 5 <20><><EFBFBD><EFBFBD><EFBFBD>: ");
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 | <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2 | <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
3 | <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
4 | <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
char* L3Z5() {
char* ans = "";
int season;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>\n");
printf("1) <20><><EFBFBD><EFBFBD>\n");
printf("2) <20><><EFBFBD><EFBFBD><EFBFBD>\n");
printf("3) <20><><EFBFBD><EFBFBD>\n");
printf("4) <20><><EFBFBD><EFBFBD><EFBFBD>\n");
scanf_s("%d", &season);
while (!(1 <= season && season <= 4)) {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>\n");
printf("1) <20><><EFBFBD><EFBFBD>\n");
printf("2) <20><><EFBFBD><EFBFBD><EFBFBD>\n");
printf("3) <20><><EFBFBD><EFBFBD>\n");
printf("4) <20><><EFBFBD><EFBFBD><EFBFBD>\n");
scanf_s("%d", &season);
}
if (season == 1) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if (season == 2) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if (season == 3) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
printf("%s", ans);
return ans;
}
/*
tests:
input | output
1 | <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
264000 | <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
3567904 | <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
char* L3Z6() {
float price;
char* ans = "";
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = ");
scanf_s("%f", &price);
if (price <= 250000) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if (price > 250000 && price <= 700000) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if (price > 700000 && price <= 1000000) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if (price > 1000000 && price <= 100000000) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
printf("%s", ans);
return ans;
}
/*
tests:
input | output
1 | <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
123 | <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
735 | <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
9090 | <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
char* L3Z7() {
float ms;
char* ans = "";
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = ");
scanf_s("%f", &ms);
if (ms <= 1) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if (ms > 1 && ms <= 2) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if (ms > 2 && ms <= 100) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if (ms > 100 && ms <= 1000) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if (ms > 1000 && ms <= 5000) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else if (ms > 5000 && ms <= 10000) {
ans = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
printf("%s", ans);
return ans;
}