Advertisement
NoxScourge

Untitled

Sep 9th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include "stdio.h"
  2.  
  3. void main() {
  4.  
  5. int oblastA = 0, oblastB = 0, oblastC = 0;
  6. int n, i;
  7. int x, y;
  8. float procenatA, procenatB, procenatC;
  9.  
  10.  
  11. printf("Unosite koordinate i pogadjate oblasti, a mi racunamo procenat pogodjenih:\n");
  12. printf("Unesite koliko zelite puta koordinate x i y da unesete:\n");
  13.  
  14. scanf("%d", &n);
  15.  
  16. printf("Unesite koordinatu x i y");
  17.  
  18. for (i = 0;i < n;i++) {
  19.  
  20. scanf("%d%d", &x, &y);
  21.  
  22. if ((x - 7)*(x - 7) + (y - 5)*(y - 5) <= 4 && y >= 4 && x >= 6 && y <= 6 && x <= 8) {
  23.  
  24. oblastB++;
  25. }
  26. else if ((x - 3)*(x - 3) + (y - 3)*(y - 3) <= 4 && (y <= 3 || x <= 3)) { //sece tako zapamti!
  27. oblastA++;
  28. }
  29. else {
  30. oblastC++;
  31. }
  32. }
  33.  
  34. procenatB = oblastB * 100 / n;
  35. procenatA = oblastA * 100 / n;
  36. procenatC = oblastC * 100 / n;
  37.  
  38.  
  39. printf("oblast A = %.2f %\n ", procenatA);
  40. printf("oblast B = %.2f %\n ", procenatB);
  41. printf("oblast C = %.2f %\n ", procenatC);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement