黑默丁格的炮台

 

 1 #include <iostream>
 2 #include <math.h>
 3 using namespace std;
 4 
 5 typedef struct  Dot
 6 {
 7     int x;
 8     int y;
 9 }Dot;
10 
11 Dot dot[4];
12 int main()
13 {
14 
15     int targetShock = 0;
16     int R = 0;
17     cin >> R;
18     for (int i = 0; i < 8; i++)
19     {
20         if (i % 2 == 0)
21         {
22             cin >> dot[i / 2].x;
23         }
24         else
25         {
26             cin >> dot[i / 2].y;
27         }
28 
29     }
30 
31     int targetX = dot[3].x;
32     int targetY = dot[3].y;
33 
34     for (int i = 0; i < 3; i++)
35     {
36         int dis = pow(dot[i].x - targetX, 2) + pow(dot[i].y - targetY, 2);
37         if (dis <= pow(R, 2))
38         {
39             targetShock++;
40         }
41 
42     }
43 
44     cout << targetShock << "X";
45 
46 
47     return 0;
48 }

 

posted @ 2015-10-10 12:43  hhboboy  阅读(204)  评论(0编辑  收藏  举报