Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <string.h>
- #include <stdlib.h>
- #include <math.h>
- #include <string.h>
- struct extraction
- {
- int years;
- float coal;
- float oil;
- float gas;
- float shale;
- };
- void s_p( struct extraction temp)
- {
- printf( "%d year %4.1f coal %4.1f oil %4.1f gas %4.1f shale\n",
- temp.years, temp.coal,temp.oil,temp.gas,temp.shale);
- }
- int j=0;
- struct extraction fuel[];
- void s_f()
- {
- int i=0,n,l;
- do
- {
- printf("Enter n@");
- scanf("%d",&n);
- if(n!=1)
- {
- break;
- }
- printf("Enter your array data %d\n",i);
- printf("Enter years:");
- scanf("%d",&fuel[j].years);
- printf("Enter coal:");
- scanf("%f",&fuel[j].coal);
- printf("Enter oil:");
- scanf("%f",&fuel[j].oil);
- printf("Enter gas:");
- scanf("%f",&fuel[j].gas);
- printf("Enter shale:");
- scanf("%f",&fuel[j].shale);
- s_p(fuel[j]);
- j++;
- }
- while(n==1);
- printf("%d",i);
- system("pause");
- }
- int main()
- { system("color F0");
- int i,B,y,k,l;
- float min,N,min1;
- //array enter data
- s_f();
- printf("%d",j);
- printf("%d",fuel[0].years);
- y=fuel[0].years;
- min=fuel[0].coal;
- for(i=1;i<j;i++)
- {
- if(fuel[i].coal<min)
- min=fuel[i].coal,
- y=fuel[i].years;
- }
- printf( "Min extraction of coal was in %d coal %1.f \n",y,min);
- printf("Your table\n");
- puts("-------------------------------------------------------------------");
- printf(" !-Years-!-Coal-!-Oil-!-Gas-!-Shale-!\n");
- for (i=0;i<j;i++)
- { puts("-------------------------------------------------------------------");
- s_p(fuel[i]);
- puts("-------------------------------------------------------------------");
- }
- //point 2
- printf("Enter the number of oil extraction (N)");
- scanf("%f",&N);
- for(i=0;i<j;i++)
- {
- if(fuel[i].oil>N)
- printf("Oil extraction is %f in %d\n",fuel[i].oil,fuel[i].years);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement