-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathp1.cpp
More file actions
31 lines (25 loc) · 644 Bytes
/
Copy pathp1.cpp
File metadata and controls
31 lines (25 loc) · 644 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "ADTList.cpp"
template<typename T>
void BubbleSort(T &list){
for(auto i=list.end();i!=list.begin();--i)
for(auto j=list.begin(),k=++(list.begin());k!=i;++j,++k)
if(*j>*k)
swap(*j,*k);
}
int main(){
int n; cin>>n;
SquList<int> list1(n);
LinkList<int> list2;
for(int i=0,x;i<n;i++){
cin>>x;
list2.push_back(x);
list1.setElem(i,x);
}
cout<<"SeqList:"<<endl;
BubbleSort(list1);
cout<<"After sort(): "; list1.traverse();
cout<<"LinkList:"<<endl;
BubbleSort(list2);
cout<<"After sort(): "; list2.traverse();
return 0;
}