#include<iostream>
using namespace std;
struct Danh_Sach
{
char Ten[100];
double diem;
};
typedef struct Danh_Sach Chuc;
void Nhap(Chuc *a,int n)
{
if(n==0)
return;
Nhap(a,n-1);
fflush(stdin);
cout<<"\nNhap Thong Tin: ";
cout<<"\nNhap Ten thu: ";cin.get(a[n-1].Ten,100);
cout<<"\nNhap Diem :";cin>>a[n-1].diem;
}
void Xuat(Chuc *a,int n,int i=0)
{
if(i==n)
return;
cout<<"\nThong Tin Thu: "<<i+1;
cout<<"\nTen thu: "<<i+1<<"\t"<<a[i].Ten;
cout<<"\nDiem :"<<a[i].diem;
return Xuat(a,n,i+1);
}
void HoanVi(Chuc &a,Chuc &b)
{
Chuc c=a;a=b;b=c;
}
void XapXep(Chuc *a,int n,int i=0)
{
if(i==n)
return ;
for(int j=i+1;j<n;j++)
{
if(a[i].diem>a[j].diem)
{
HoanVi(a[i],a[j]);
}
return XapXep(a,n,i+1);
}
}
int main()
{int n;
cout<<"Nhap Vao So Luong Sinh Vien";cin>>n;
Chuc *a=new Chuc[n];
Nhap(a,n);
XapXep(a,n);
cout<<"\n====================================================\n";
cout<<"Danh Sach Sau Khi Xap Xep Se La:\n";
Xuat(a,n);
cout<<endl;
delete[] a;
system("pause");
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.