Advertisement
iasmina_sarac

Untitled

Jan 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include<iostream>
  2. 02.
  3. #include<cmath>
  4. 03.
  5. using namespace std;
  6. 04.
  7. struct pct
  8. 05.
  9. {
  10. 06.
  11. int x,y;
  12. 07.
  13. };
  14. 08.
  15. void citire(pct&P)
  16. 09.
  17. {
  18. 10.
  19. cin>>P.x>>P.y;
  20. 11.
  21. }
  22. 12.
  23. int dist(pct P)
  24. 13.
  25. {
  26. 14.
  27. return P.x*P.x+P.y*P.y;
  28. 15.
  29. }
  30. 16.
  31. int main()
  32. 17.
  33. {
  34. 18.
  35. int n,k,pMax=-1;
  36. 19.
  37. pct A;
  38. 20.
  39. cin>>n;
  40. 21.
  41. for(int i=1;i<= n;i++)
  42. 22.
  43. {
  44. 23.
  45. citire(A);
  46. 24.
  47. int pd=dist(A);
  48. 25.
  49. if(pd>pMax)
  50. 26.
  51. pMax=pd,k=1;
  52. 27.
  53. else
  54. 28.
  55. if(pd==pMax)
  56. 29.
  57. k++;
  58. 30.
  59. }
  60. 31.
  61. cout<<sqrt(pMax)<<" "<<k;
  62. 32.
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement