Chào,
Ban nào có kinh nghiệm struct và selection sort chỉ mình cái dòng này fix làm sao ?
void SelectionSort(int arr[], int n)
{
int i, j, temp;
for ( i = 0 ; i <= n-1 ; i++ )
{
for ( j = i + 1 ; j <= n ; j++ )
{
if ( arr[i] > arr[j] )
{
temp = arr[i] ;
arr[i] = arr[j] ;
arr[j] = temp ;
}
}
}
printf ( "Array after sorting:\n") ;
for ( i = 0 ; i <= n ; i++ )
printf ( "%d\t", arr[i] ) ;
}
main()
{
clrscr();
int n,i;
struct hinhtron
{
int ox,oy,d;
};
struct hinhtron *ht;
struct hinhtron *p;
cout<<"NHAP N : ";
cin>>n;
cout<<"\n";
for(i=0;i<=n;i++)
{
cout<<"NHAP Ox : ";
cin>>ht[i].ox;
cout<<"\n";
cout<<"NHAP Oy : ";
cin>>ht[i].oy;
ht[i].d=sqrt((pow(ht[i].ox,2))+(pow(ht[i].oy,2)));
}
SelectionSort(ht.d,n); -----------> CÁI DÒNG NÀY SỬA LÀM SAO AI BIK GIÚP VS
getch();
}
Bookmarks