Advertisement
Guest User

Untitled

a guest
May 27th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5. int n,m,k,b,maks;
  6. int energia[100][4];
  7. int max[100];
  8. int max1[100];
  9. int odbiorcy(int n);
  10. int main() {
  11. printf("Podaj ilość odbiorców ");
  12. scanf("%i",&n);
  13. odbiorcy(n);
  14. wypisz(n);
  15. return 0;
  16. }
  17.  
  18.  
  19. int odbiorcy(int n)
  20. {
  21. maks=0;
  22. for(k=0;k<n;k++)
  23. {
  24. for(b=0;b<4;b++)
  25. {
  26. printf("Podaj wartość energi odbiorcy nr %i w kwartale %i ",k+1,b+1);
  27. scanf("%i",&energia[k][b]);
  28. if(maks<energia[k][b])
  29. {
  30.  
  31. maks=energia[k][b];
  32. max[k]=b+1;
  33. max1[k]=maks;
  34. }
  35. }
  36. }
  37. }
  38.  
  39. int wypisz(int n)
  40. {
  41. for(k=0;k<n;k++)
  42. {
  43. printf("Najwyższa wartość pobranej energii przez odbiorce nr %i była w kwartale %i a jej wartość to %i\n\n",k+1,max[k],max1[k]);
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement