Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #define size 100
  4. using namespace std;
  5. struct MANGDIEM
  6. {
  7. float x;
  8. float y;
  9. }A[size];
  10. void nhapxuat(int &n)
  11. {
  12. //int n;
  13. cout<<"co so diem la ";
  14. cin>> n;
  15. cout<<"\nnhap toa do cac diem";
  16. for(int i=1;i<=n;i++)
  17. {
  18. cout<<"\ndiem thu ["<<i<<"]"<<" co hoanh do,tung do lan luot la ";
  19. cin>>A[i].x>>A[i].y;
  20. }
  21. for(int i=1;i<=n;i++)
  22. {
  23. cout<<"\ndiem thu ["<<i<<"] la ("<<A[i].x<<";"<<A[i].y<<")";
  24. }
  25. }
  26. void dem()
  27. {
  28. int n;
  29. int dem1=0;
  30. for(int i=1;i<=n;i++)
  31. {
  32. if(A[i].x>0)
  33. dem1++;
  34. }
  35. cout<<"\nco "<<dem1<<" diem co hoanh do duong";
  36. }
  37. void diemtrung()//tim diem trung nhau
  38. {
  39. int n,dem=0;
  40. for(int i=1;i<=n;i++)
  41. {
  42. for(int j=1;j<i;j++)
  43. {
  44. if(A[i].x==A[j].x&&A[i].y==A[j].y)
  45. dem++;
  46. }
  47. }
  48. cout<<dem;
  49. }
  50. void timmax()//tim hoanh do max
  51. {
  52. int n,max = A[0].x;
  53. for (int i = 1; i < n; i++)
  54. {
  55. if (max < A[i].x)
  56. max = A[i].x;
  57. }
  58. cout<<max;
  59. }
  60. int main()
  61. {
  62. int n;
  63. nhapxuat(n);
  64. dem();
  65. diemtrung();
  66. timmax();
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement