Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. struct ulaz1{
  4. int idK;
  5. int idP;
  6. int dat;
  7. float uk;
  8. };
  9.  
  10. void ispisi_rezultat(int koji_dan, float sum) {
  11. FILE *f;
  12. f = fopen("max.txt", "w");
  13. if (f==NULL) printf("Greska pri otvaranju filea!");
  14. fprintf(f, "%d: %.2f", koji_dan, sum);
  15. }
  16.  
  17. int main(void) {
  18. struct ulaz1 ulaz[1000];
  19. int x, rezultat,i,j;
  20. float sum;
  21. float br_dana[365];
  22. sum=0;
  23. scanf("%d\n",&x);
  24. for(i = 0; i < x; i++){
  25. scanf("%d%d%d%f", &ulaz[i].idK, &ulaz[i].idP, &ulaz[i].dat, &ulaz[i].uk);
  26. }
  27.  
  28. for(i = 0; i <= 365; i++)
  29. {
  30. for(j = 0; j < x; j++)
  31. {
  32. if(ulaz[j].dat==i)
  33. br_dana[i]=br_dana[i]+ulaz[j].uk;
  34. }
  35.  
  36. }
  37. for(i = 0; i < 366; i++) {
  38.  
  39. if(br_dana[i]>sum){
  40. sum=br_dana[i];
  41. rezultat=i;
  42.  
  43. }
  44.  
  45. }
  46.  
  47. ispisi_rezultat(rezultat,sum);
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement