Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int IndexNajveceg (int *niz, int vel) {
- int i=0,ind=0,maxi;
- maxi=*niz;
- for (i=0; i<vel;i++) {
- if (*(niz+i)>maxi) {
- maxi=*(niz+i);
- ind=i;
- }
- }
- return ind;
- }
- int main () {
- FILE *ulaz=fopen("temperature.txt","r");
- if (ulaz==NULL) {
- printf("Greska prilikom otvaranja ulazne datoteke.");
- exit(1);
- }
- FILE *izlaz=fopen("statistika.txt","w");
- {
- if (izlaz==NULL) {
- printf("Greska prilikom otvaranja izlazne datoteke.");
- fclose(ulaz);
- exit(1);
- }
- }
- int niz[1000];
- int i=0;
- char c;
- do{
- fscanf(ulaz,"%d",&niz[i+1]);
- i++;
- } while ((c=fgetc(ulaz))!=EOF && i<1000);
- int rez=IndexNajveceg(niz,i);
- fprintf(izlaz,"%.2f",rez);
- fclose(ulaz);
- close(izlaz);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement