Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
BubDoubArray
//g++ 7.4.0 //Templated Bubble Sort in Double Linked List ( Using Array) //code is created by Rezaul Hoque on March 12 on 2021 //please contact at jewelmrh@yahoo.com #include <iostream> #include <bits/stdc++.h> using namespace std; template <class T> class node { public: T val; node<T> *next; node<T> *prev; void bubble(node<T> a[], T n) { T temp, i,j; for (T i=0; i<n; i++) { for (T j=0; j<n; j++) { if( a[i].val < a[j].val){ temp = a[i].val; a[i].val = a[j].val; a[j].val = temp; } } } } }; int main() { const int max=3; node<int>* a; a = new node<int>[max]; a[0].prev=NULL; a[2].next = NULL; for(int i=0; i<3; i++) { a[i].next = a[i+2].prev; } a[0].val={5}; a[1].val={4}; a[2].val={2}; cout<<"After bubble sort:\n"; a->bubble(a,3); for (int i= 0; i<max; i++) { cout<<" "<<a[i].val; } return 0; }
run
|
edit
|
history
|
help
0
ThreadPool
Jilebi Nimki
Size of data type test
Interview Prep
CPP - Arrays - Ex.3
Scemo
Varadic macro
23 2.5
Vectores - insertar ordenado e imprimir
shuffle_example