Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- void main() {
- int oblastA = 0, oblastB = 0, oblastC = 0;
- int n, i;
- int x, y;
- float procenatA, procenatB, procenatC;
- printf("Unosite koordinate i pogadjate oblasti, a mi racunamo procenat pogodjenih:\n");
- printf("Unesite koliko zelite puta koordinate x i y da unesete:\n");
- scanf("%d", &n);
- printf("Unesite koordinatu x i y");
- for (i = 0;i < n;i++) {
- scanf("%d%d", &x, &y);
- if ((x - 7)*(x - 7) + (y - 5)*(y - 5) <= 4 && y >= 4 && x >= 6 && y <= 6 && x <= 8) {
- oblastB++;
- }
- else if ((x - 3)*(x - 3) + (y - 3)*(y - 3) <= 4 && (y <= 3 || x <= 3)) { //sece tako zapamti!
- oblastA++;
- }
- else {
- oblastC++;
- }
- }
- procenatB = oblastB * 100 / n;
- procenatA = oblastA * 100 / n;
- procenatC = oblastC * 100 / n;
- printf("oblast A = %.2f %\n ", procenatA);
- printf("oblast B = %.2f %\n ", procenatB);
- printf("oblast C = %.2f %\n ", procenatC);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement