Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- #define size 100
- using namespace std;
- struct MANGDIEM
- {
- float x;
- float y;
- }A[size];
- void nhapxuat(int &n)
- {
- //int n;
- cout<<"co so diem la ";
- cin>> n;
- cout<<"\nnhap toa do cac diem";
- for(int i=1;i<=n;i++)
- {
- cout<<"\ndiem thu ["<<i<<"]"<<" co hoanh do,tung do lan luot la ";
- cin>>A[i].x>>A[i].y;
- }
- for(int i=1;i<=n;i++)
- {
- cout<<"\ndiem thu ["<<i<<"] la ("<<A[i].x<<";"<<A[i].y<<")";
- }
- }
- void dem()
- {
- int n;
- int dem1=0;
- for(int i=1;i<=n;i++)
- {
- if(A[i].x>0)
- dem1++;
- }
- cout<<"\nco "<<dem1<<" diem co hoanh do duong";
- }
- void diemtrung()//tim diem trung nhau
- {
- int n,dem=0;
- for(int i=1;i<=n;i++)
- {
- for(int j=1;j<i;j++)
- {
- if(A[i].x==A[j].x&&A[i].y==A[j].y)
- dem++;
- }
- }
- cout<<dem;
- }
- void timmax()//tim hoanh do max
- {
- int n,max = A[0].x;
- for (int i = 1; i < n; i++)
- {
- if (max < A[i].x)
- max = A[i].x;
- }
- cout<<max;
- }
- int main()
- {
- int n;
- nhapxuat(n);
- dem();
- diemtrung();
- timmax();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement