-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP1SO-program4.c
More file actions
83 lines (73 loc) · 1.56 KB
/
P1SO-program4.c
File metadata and controls
83 lines (73 loc) · 1.56 KB
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
#include <stdio.h>
#include <stdlib.h>
typedef struct Datos{
char caracter;
float flotante;
long long int entero64;
}masDatos;
typedef struct NC{
int entero;
double doble;
masDatos otros;
struct NC *sig;
} *NodoC;
typedef struct Nodo{
NodoC prim;
NodoC ult;
}*Cola;
Cola new(){
Cola temp=(Cola) malloc (1*sizeof(struct Nodo));
temp->prim=temp->ult=NULL;
return temp;
}
Cola push(Cola q, int ent, double dob, masDatos otr){
NodoC temp=(NodoC) malloc (sizeof(struct NC));
Cola tempc= new();
temp->entero=ent;
temp->doble=dob;
temp->otros=otr;
if(q->prim==NULL) tempc->prim=tempc->ult=temp;
else{
q->ult->sig=temp;
tempc->prim=q->prim;
tempc->ult=temp;
//q->ult=temp;
}
return tempc;
}
Cola pop(Cola q){ //Desformar
Cola tempc=new();
if(q->prim==q->ult){
return tempc;
}
else{
tempc->prim=q->prim->sig;
tempc->ult=q->ult;
return tempc;
}
}
Cola front(Cola q){
printf("Entero: %d\nDoble: %lf\n",q->prim->entero,q->prim->doble);
printf("Otros datos\n");
printf("Caracter: %c\n",q->prim->otros.caracter);
printf("Flotante: %f\n",q->prim->otros.flotante);
printf("Entero de 64 bits: %lld\n",q->prim->otros.entero64);
printf("\n");
}
int main(){
Cola a=new();
masDatos otros;
otros.caracter='c';
otros.flotante=24.25;
otros.entero64=56999999999;
masDatos otros1;
otros1.caracter='z';
otros1.flotante=78.98;
otros1.entero64=99009999999;
a=push(a,1,3.1416,otros);
a=push(a,5,29.06,otros1);
front(a);
a=pop(a);
front(a);
return 0;
}