Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <locale.h>
- struct england
- {
- int year;
- unsigned all_expenses;
- float military_expenses;
- int def_or_exc;
- unsigned debt;
- };
- struct
- {
- int year;
- unsigned all_expenses;
- float military_expenses;
- int def_or_exc;
- unsigned debt;
- } arr_result[200];
- int main()
- {
- setlocale(LC_ALL, "russian");
- int error, counter;
- do
- {
- printf("Данные за сколько лет вы хотите внести?\n");
- scanf("%d", &counter);
- if (counter <= 0)
- {
- error = 1;
- printf("Вы ошиблись!\n");
- }
- else error = 0;
- } while (error);
- printf("Ввведите данные о стране в виде: год, всего расходов,"
- "военные расходы, дефицит или превышение, государственный долг\n");
- for (int i = 0; i < counter; i++)
- {
- scanf("%d", &arr_result[i].year);
- scanf("%d", &arr_result[i].all_expenses);
- scanf("%f", &arr_result[i].military_expenses);
- scanf("%d", &arr_result[i].def_or_exc);
- scanf("%d", &arr_result[i].debt);
- }
- double min = arr_result[0].def_or_exc;
- int min_year = 0;
- /*====================Расчет максимального дефицита бюджета Англии======================*/
- for (int i = 0; i < counter; i++)
- {
- if (min > arr_result[i].def_or_exc)
- {
- min = arr_result[i].def_or_exc;
- min_year = arr_result[i].year;
- }
- }
- printf("Год максимального дефицита: %d, его значение: %f\n", min_year, min);
- /*==================Конец расчета максимального дефицита бюджета Англии====================*/
- double m;
- printf("Введите значение М\n");
- scanf("%f", &m);
- for (int i = 0; i < counter; i++)
- {
- if (m < arr_result[i].debt)
- {
- printf("%d\n", arr_result[i].debt);
- }
- else
- {
- printf("Стран с долгом, превышающим М не найдено");
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement