Advertisement
Lustacho

Untitled

Nov 5th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.33 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. #include <math.h>
  7. #include <string.h>
  8. struct extraction
  9.     {
  10.      int years;
  11.      float coal;
  12.      float oil;
  13.      float gas;
  14.      float shale;
  15.     };
  16.         void s_p( struct extraction temp)
  17.     {
  18.         printf(  "%d year  %4.1f coal   %4.1f oil   %4.1f gas   %4.1f shale\n",
  19.                temp.years, temp.coal,temp.oil,temp.gas,temp.shale);
  20.     }
  21.     int j=0;
  22.     struct extraction fuel[];
  23.         void s_f()
  24.     {
  25.     int i=0,n,l;
  26.     do
  27.         {
  28.             printf("Enter n@");
  29.             scanf("%d",&n);
  30.             if(n!=1)
  31.         {
  32.         break;
  33.         }
  34.             printf("Enter your array data %d\n",i);
  35.             printf("Enter years:");
  36.             scanf("%d",&fuel[j].years);
  37.             printf("Enter coal:");
  38.             scanf("%f",&fuel[j].coal);
  39.             printf("Enter oil:");
  40.             scanf("%f",&fuel[j].oil);
  41.             printf("Enter gas:");
  42.             scanf("%f",&fuel[j].gas);
  43.             printf("Enter shale:");
  44.             scanf("%f",&fuel[j].shale);
  45.             s_p(fuel[j]);
  46.             j++;
  47.         }
  48.     while(n==1);
  49.     printf("%d",i);
  50.     system("pause");
  51.     }
  52.     int main()
  53.     {   system("color F0");
  54.         int i,B,y,k,l;
  55.         float min,N,min1;
  56.  
  57.     //array enter data
  58.         s_f();
  59.         printf("%d",j);
  60.  
  61.         printf("%d",fuel[0].years);
  62.         y=fuel[0].years;
  63.         min=fuel[0].coal;
  64.         for(i=1;i<j;i++)
  65.     {
  66.         if(fuel[i].coal<min)
  67.         min=fuel[i].coal,
  68.         y=fuel[i].years;
  69.     }
  70.  
  71.        printf( "Min extraction of coal was in %d coal %1.f \n",y,min);
  72.         printf("Your table\n");
  73.         puts("-------------------------------------------------------------------");
  74.         printf("       !-Years-!-Coal-!-Oil-!-Gas-!-Shale-!\n");
  75.     for (i=0;i<j;i++)
  76.     {   puts("-------------------------------------------------------------------");
  77.         s_p(fuel[i]);
  78.          puts("-------------------------------------------------------------------");
  79.     }
  80.     //point 2
  81.     printf("Enter the number of oil extraction (N)");
  82.     scanf("%f",&N);
  83.         for(i=0;i<j;i++)
  84.         {
  85.             if(fuel[i].oil>N)
  86.                 printf("Oil extraction is %f in %d\n",fuel[i].oil,fuel[i].years);
  87.         }
  88.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement