Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int szamok[10];
- int sum=0;
- int x=0;
- int avg;
- int j;
- int ln;
- int lk;
- int osszeg(int x)
- {
- for(j=1;j<x;j++)
- {
- sum=sum+szamok[j];
- }
- return sum;
- }
- double atlag(int x)
- {
- for(j=1;j<11;j++)
- {
- avg=avg+szamok[j];
- }
- return avg/x;
- }
- int legn(int x)
- {
- int ln=szamok[0];
- for(j=1;j<x;j++)
- {
- if(szamok[j]>ln)
- {
- ln=szamok[j];
- }
- }
- return ln;
- }
- int legk(int x)
- {
- int lk=szamok[0];
- for(j=1;j<x;j++)
- {
- if(szamok[j]<lk)
- {
- lk=szamok[j];
- }
- }
- return lk;
- }
- int main()
- {
- FILE * input;
- FILE * output;
- input=fopen("input.txt","r");
- while(!feof(input))
- {
- fscanf(input,"%d",&szamok[x]);
- }
- output=fopen("output.txt","w");
- fprintf(output,"%d %d %d %lf",legk(x),legn(x),osszeg(x),atlag(x));
- fclose(input);
- fclose(output);
- return 0;
- }
Add Comment
Please, Sign In to add comment