Advertisement
Guest User

Untitled

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