Me podr铆an ayudar a resolver el fin de m贸dulo 5 el de gesti贸n de colas por fa | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Me podr铆an ayudar a resolver el fin de m贸dulo 5 el de gesti贸n de colas por fa

27th Apr 2021, 3:43 AM
Nicole Tatiana Beltr谩n Su谩rez
Nicole Tatiana Beltr谩n Su谩rez - avatar
6 Answers
+ 1
Espero que te sirva de gu铆a #include <iostream> using namespace std; template <class T> class Queue{ private : int size; T* queue; public: Queue() { size = 0; queue = new T [100]; } void add(T data) { queue[size] = data; size++; } void remove() { if (size == 0) { cout << "Queue is empty"<<endl; return; } else { for (int i = 0; i < size - 1; i++) { queue[i] = queue[i + 1]; } size--; } } void print() { if (size == 0) { cout << "Queue is empty"<<endl; return; } for (int i = 0; i < size; i++) { cout<<queue[i]<<" <- "; } cout << endl; } }; int main() { Queue<int> q1; q1.add(42); q1.add(2); q1.add(8); q1.add(1); q1.print(); Queue<string> q2; q2.add("Dave"); q2.add("John"); q2.add("Amy"); q2.print(); return 0; }
28th Apr 2021, 4:19 AM
Luis Andr茅s Valido Fajardo 馃嚚馃嚭
Luis Andr茅s Valido Fajardo 馃嚚馃嚭 - avatar
+ 1
// esta es la verdadera soluci贸n #include <iostream> using namespace std; template <class T> class Queue{ private : int size; T* queue; public: Queue() { size = 0; queue = new T [100]; } void add(T data) { queue[size] = data; size++; } void remove() { if (size == 0) { cout << "Queue is empty"<<endl; return; } else { for (int i = 0; i < size - 1; i++) { queue[i] = queue[i + 1]; } size--; } } void print() { if (size == 0) { cout << "Queue is empty"<<endl; return; } for (int i = 0; i < size; i++) { cout<<queue[i]<<" <- "; } cout << endl; } }; int main() { Queue<int> q1; q1.add(42); q1.add(2); q1.add(8); q1.add(1); q1.print(); Queue<int>q2; q2.add(2); q2.add(8); q2.add(1); q2.add(128); q2.print(); Queue<int>q3; q3.add(1);q3.add(128); q3.print(); return 0; }
20th Dec 2021, 9:06 PM
Jhon Palmieri Meza
Jhon Palmieri Meza - avatar
0
//tu c贸digo va aqui void add(int n) { queue[size] = n; size++; } Asi Cree la funcion Add Espero que te sirva !
12th Oct 2021, 1:08 AM
Jhon Stiven Caicedo Mosquera
Jhon Stiven Caicedo Mosquera - avatar
0
Hola buenas noches
19th Nov 2021, 6:36 AM
Perla Hern谩ndez Guevara
Perla Hern谩ndez Guevara - avatar
0
Me puedes ayudar en sacar el c贸digo
19th Nov 2021, 6:36 AM
Perla Hern谩ndez Guevara
Perla Hern谩ndez Guevara - avatar
0
Espero te sirva //tu c贸digo va aqu铆 Queue operator+(Queue obj) { Queue result; result.size = this ->size; result.queue = this ->queue; int length=obj.size; int n=0; while(n<length) { result.add(obj.queue[n]); n++; } return result; }
23rd Aug 2022, 2:43 PM
Janer Leal Hernandez
Janer Leal Hernandez - avatar