pasar este código de "C++" a C
Publicado por Lisardo (1 intervención) el 07/03/2019 04:40:43
Buenas noches, necesito por favor pasar este código de "C++" a C, muchas gracias en lo que me puedan ayudar
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include <iostream>
using namespace std;
struct nodo
{
int nro;
struct nodo *sgte;
};
struct cola
{
nodo *delante;
nodo *atras ;
};
void encolar( struct cola &q, int valor )
{
struct nodo *aux = new(struct nodo);
aux->nro = valor;
aux->sgte = NULL;
if( q.delante == NULL)
q.delante = aux;
else
(q.atras)->sgte = aux;
q.atras = aux;
}
int desencolar( struct cola &q )
{
int num ;
struct nodo *aux ;
aux = q.delante;
num = aux->nro;
q.delante = (q.delante)->sgte;
delete(aux);
return num;
}
void muestraCola( struct cola q )
{
struct nodo *aux;
aux = q.delante;
while( aux != NULL )
{
cout<<" "<< aux->nro ;
aux = aux->sgte;
}
}
void vaciaCola( struct cola &q)
{
struct nodo *aux;
while( q.delante != NULL)
{
aux = q.delante;
q.delante = aux->sgte;
delete(aux);
}
q.delante = NULL;
q.atras = NULL;
}
void menu()
{
cout<<"\n\t IMPLEMENTACION DE COLAS EN C++\n\n";
cout<<" 1. ENCOLAR "<<endl;
cout<<" 2. DESENCOLAR "<<endl;
cout<<" 3. MOSTRAR COLA "<<endl;
cout<<" 4. VACIAR COLA "<<endl;
cout<<" 5. SALIR "<<endl;
cout<<"\n INGRESE OPCION: ";
}
int main()
{
struct cola q;
q.delante = NULL;
q.atras = NULL;
int dato;
int op;
int x ;
system("color 0b");
do
{
menu(); cin>> op;
switch(op)
{
case 1:
cout<< "\n NUMERO A ENCOLAR: "; cin>> dato;
encolar( q, dato );
cout<<"\n\n\t\tNumero " << dato << " encolado...\n\n";
break;
case 2:
x = desencolar( q );
cout<<"\n\n\t\tNumero "<< x <<" desencolado...\n\n";
break;
case 3:
cout << "\n\n MOSTRANDO COLA\n\n";
if(q.delante!=NULL) muestraCola( q );
else cout<<"\n\n\tCola vacia...!"<<endl;
break;
case 4:
vaciaCola( q );
cout<<"\n\n\t\tHecho...\n\n";
break;
}
cout<<endl<<endl;
system("pause"); system("cls");
}while(op!=5);
return 0;
}
Valora esta pregunta


0