Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.18 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include <conio.h>
  6. #include <stdlib.h>
  7. #include <math.h>
  8. #include <locale.h>
  9.  
  10.  
  11.  
  12. struct england
  13. {
  14.     int year;
  15.     unsigned all_expenses;
  16.     float military_expenses;
  17.     int def_or_exc;
  18.     unsigned debt;
  19.    
  20. };
  21. struct
  22. {
  23.     int year;
  24.     unsigned all_expenses;
  25.     float military_expenses;
  26.     int def_or_exc;
  27.     unsigned debt;
  28. } arr_result[200];
  29.  
  30. int main()
  31. {
  32.     setlocale(LC_ALL, "russian");
  33.     int error, counter;
  34.  
  35.     do
  36.     {
  37.         printf("Данные за сколько лет вы хотите внести?\n");
  38.         scanf("%d", &counter);
  39.        
  40.         if (counter <= 0)
  41.         {
  42.             error = 1;
  43.             printf("Вы ошиблись!\n");
  44.            
  45.  
  46.         }
  47.         else error = 0;
  48.     } while (error);
  49.  
  50.  
  51.    
  52.     printf("Ввведите данные о стране в виде: год, всего расходов,"
  53.         "военные расходы, дефицит или превышение, государственный долг\n");
  54.    
  55.     for (int i = 0; i < counter; i++)
  56.     {
  57.        
  58.         scanf("%d", &arr_result[i].year);
  59.         scanf("%d", &arr_result[i].all_expenses);
  60.         scanf("%f", &arr_result[i].military_expenses);
  61.         scanf("%d", &arr_result[i].def_or_exc);
  62.         scanf("%d", &arr_result[i].debt);
  63.  
  64.     }
  65.    
  66.     double min = arr_result[0].def_or_exc;
  67.     int min_year = 0;
  68.     /*====================Расчет максимального дефицита бюджета Англии======================*/
  69.     for (int i = 0; i < counter; i++)
  70.     {
  71.        
  72.         if (min > arr_result[i].def_or_exc)
  73.         {
  74.             min = arr_result[i].def_or_exc;
  75.             min_year = arr_result[i].year;
  76.         }
  77.     }
  78.     printf("Год максимального дефицита: %d, его значение: %f\n", min_year, min);
  79.    
  80.     /*==================Конец расчета максимального дефицита бюджета Англии====================*/
  81.     double m;
  82.     printf("Введите значение М\n");
  83.     scanf("%f", &m);
  84.     for (int i = 0; i < counter; i++)
  85.     {
  86.         if (m < arr_result[i].debt)
  87.         {
  88.             printf("%d\n", arr_result[i].debt);
  89.         }
  90.         else
  91.         {
  92.             printf("Стран с долгом, превышающим М не найдено");
  93.         }
  94.     }
  95.    
  96.     system("pause");
  97.     return 0;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement