Ayuda con un ejercicio de C
Publicado por María José Yépez (1 intervención) el 25/04/2016 06:37:54
Estimados:
Por favor su gentil ayuda con el siguiente código, ya que no se imprimen los datos, el código es el siguiente:
Quedo a la espera de su gentil respuesta
Por favor su gentil ayuda con el siguiente código, ya que no se imprimen los datos, el código es el siguiente:
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
#include<stdio.h>
#include<conio.h>
#include<string.h>
struct televisor
{
char tvmarca[25];
char tvmodelo[25];
int tvtam;
float precio;
char tvsma;
} tv;
int ingreso(televisor *&tvregistro);
int ordenar(televisor *&tvregistro);
int imprimir(televisor *&tvregistro);
int numtv,i,j;
int main()
{
int opmenu;
televisor *registro = new televisor[10];
numtv=0;
do
{
printf("\n tM E N U");
printf("\n 1) I N G R E S O");
printf("\n 2) O R D E N A R");
printf("\n 3) I M P R I M I R");
printf("\n 4) F I N");
printf("\n ESCOJA UNA OPCION : ");
scanf("%d",&opmenu);
if(opmenu==1)
{
ingreso(registro);
}
else
if(opmenu==2)
{
ordenar(registro);
}
else
if(opmenu==3)
{
imprimir(registro);
}
} while(opmenu!=4);
return(0);
}
int ingreso(televisor *&tvregistro)
{
printf("\n\tMarca : ");
scanf("%s",&tvregistro[numtv].tvmarca);
printf("\n\tModelo : ");
scanf("%s",&tvregistro[numtv].tvmodelo);
printf("\n\tTamaño : ");
scanf("%d",&tvregistro[numtv].tvtam);
printf("\n\tPrecio : ");
scanf("%d",&tvregistro[numtv].precio);
do
{
printf("\n\tSmart S o N : ");
scanf("%s",&tvregistro[numtv].tvsma);
if(tvregistro[numtv].tvsma=='S'||tvregistro[numtv].tvsma=='N')
j=1;
}while(j==0);
numtv++;
return(0);
}
int ordenar(televisor *&tvregistro)
{
televisor soporte;
for(i=0;i<=numtv-1;i++)
for(j=i+1;j<=numtv;j++)
{
if(strcmp(tvregistro[i].tvmarca,tvregistro[j].tvmarca)>0)
{
strcpy(soporte.tvmarca,tvregistro[i].tvmarca);
strcpy(soporte.tvmodelo,tvregistro[i].tvmodelo);
soporte.tvtam=tvregistro[i].tvtam;
soporte.precio=tvregistro[i].precio;
soporte.tvsma=tvregistro[i].tvsma;
strcpy(tvregistro[i].tvmarca,tvregistro[j].tvmarca);
strcpy(tvregistro[i].tvmodelo,tvregistro[j].tvmodelo);
tvregistro[i].tvtam=tvregistro[j].tvtam;
tvregistro[i].precio=tvregistro[j].precio;
tvregistro[i].tvsma=tvregistro[j].tvsma;
strcpy(tvregistro[j].tvmarca,soporte.tvmarca);
strcpy(tvregistro[j].tvmodelo,soporte.tvmodelo);
tvregistro[j].tvtam=soporte.tvtam;
tvregistro[j].precio=soporte.precio;
tvregistro[j].tvsma=soporte.tvsma;
}
}
return(0);
}
int imprimir(televisor *&tvregistro)
{
printf("\n T E L E V I S O R E S ");
printf("\nMARCA MODELO TAMAÑO PRECIO SMART");
for(i=0;i<=numtv;i++)
{
printf("\n%s \t%s \t%s \t%d \t%f \t%s",tvregistro[i].tvmarca,tvregistro[i].tvmodelo,tvregistro[i].tvtam,tvregistro[i].precio,tvregistro[i].tvsma);
}
getch();
return(0);
}
Quedo a la espera de su gentil respuesta
Valora esta pregunta


0