Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
BubDoubArray2
//g++ 7.4.0 //Sorting template array using bubble sort and double linked list //code is created by Rezaul Hoque on March 21, 2021 //please contact at jewelmrh@yahoo.com #include <iostream> #include <bits/stdc++.h> using namespace std; template <class T> class node{ public: T val; int p; int q; node<T>* next; node<T>* prev; void bubble(node<T> a[], T n); }; template <class T> void node<T>::bubble(node<T> a[], T n) { T i,j; node<T> temp; for (T i=0; i<n; i++) { for (T j=0; j<n; j++) { if( a[i].val < a[j].val){ temp = a[i]; a[i] = a[j]; a[j] = temp; } } } } int main() { const int max=3; node<char>* a; a = new node<char>[max]; a[0].prev=NULL; a[2].next = NULL; for(int i=0; i<max; i++) { a[i].next = a[i+2].prev; } a[0].val={'E'}; a[1].val={'D'}; a[2].val={'C'}; a[0].p={4}; a[1].p={2}; a[2].p = {6}; a[0].q={5}; a[1].q={4}; a[2].q = {8}; cout<<"After bubble sort:\n"; a->bubble(a, max); for(int i=0; i<max; i++) { cout<<a[i].val<<"\t"<<a[i].p<<"\t"<<a[i].q<<endl; cout<<"\n"; } return 0; }
run
|
edit
|
history
|
help
0
Caminho das Pontes
g++ -Wall *.cpp -o aco; ./aco.
WeekAgenda
Click 5
3 and 7 in a row
series
cppPyProperty
How to get base class
maya angelou
count common elements in three sorted array without using extraspace