Dev - C++ - Correcion en C++

 
Vista:

Correcion en C++

Publicado por pipo (4 intervenciones) el 25/11/2018 16:19:51
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
141
142
143
144
145
146
147
148
149
150
151
/*Este es mi codigo, pero me da error, la idea es que en  mostrar_listaSaldo()
me muestra la lista de solo los saldos ingresados mayores a 250000. 
El otro error es que a la hora de imprimir en pantalla no me regresa el valor en ano de ingreso y saldo. 
Lo ultimo que queria hacer es seleccionar un elemento de la pila y eliminarlo pero que uno por eleccion y no el ultimo en la fila (el codigo esta hecho para que elimine el ultimo de la fila*/
 
 
#include <stdio.h>
#include <conio.h>
#include <malloc.h>
#include <stdlib.h>
 
int monto = 250000;
 
struct agenda
{
	char nombre[20];
	int anoIngreso[4];
	float montoCuenta [2000];
	struct agenda *siguiente;
};
 
struct agenda *ptrPrimero=NULL; //puntero global
struct agenda *ptrUltimo=NULL;
 
void mostrar_menu();
void anadir_elemento();
void mostrar_lista();
void mostrar_listaSaldo();
void eliminar_lista ();
 
 
 
int main()
{
     char opcion;
 
 
     do {
         mostrar_menu();
         opcion = getch();
         switch ( opcion )
         {
            case '1':
                anadir_elemento();
                break;
            case '2':
                mostrar_lista();
                break;
            case '3':
                mostrar_listaSaldo();
                break;
            case '4':
                eliminar_lista();
                break;
            default:
               break;
         }
     }while(opcion!='5');
}
 
void mostrar_menu()
{
	system("CLS");
	printf("\n\t\t ******BAC CREDOMATIC******\n");
	printf("\n\t\t MENU PRINCIPAL\n");
	printf("1. Nuevo \n");
	printf("2. Listar\n");
	printf("3. Lista Saldo \n");
	printf("4. Borrrar usuario  \n");
	printf("5. Salir\n");
	printf("\n Elija una opcion: ");
	fflush(stdin);
}
 
void anadir_elemento()
{
    struct agenda *ptrNuevo;
	ptrNuevo=(struct agenda *) malloc(sizeof(struct agenda));
 
	//Saber si es o no el primer nodo
	if (ptrPrimero==NULL)
	{
	  ptrPrimero=ptrNuevo;
	  ptrNuevo->siguiente=NULL;
	}
	else
	{
		ptrUltimo->siguiente=ptrNuevo;
	}
	ptrUltimo=ptrNuevo;
	printf("\n\tDigite el nombre: ");
	gets(ptrNuevo->nombre);
	fflush(stdin);
	printf("\n\tDigite el ano de ingreso: ");
	scanf("%i", ptrNuevo->anoIngreso);
	fflush(stdin);
	printf("\n\tDigite el monto en la cuenta: ");
	scanf("%f", ptrNuevo->montoCuenta);
}
 
void mostrar_lista()
{
	struct agenda *ptrRecorre=ptrPrimero;
 
	while (ptrRecorre!=NULL)
	{
		printf("\n\tUsuario: %s  Ano de Ingreso: %i    Monto en la cuenta: %f", ptrRecorre->nombre, ptrRecorre->anoIngreso, ptrRecorre->montoCuenta);
		ptrRecorre=ptrRecorre->siguiente;
	}
 
	fflush(stdin);
	getch();
}
 
void mostrar_listaSaldo()
{
	struct agenda *ptrRecorre=ptrPrimero;
 
	while ((ptrRecorre->montoCuenta) > 250000)
	{
		printf("\n\tUsuario: %s  Ano de Ingreso: %i    Monto en la cuenta: %f", ptrRecorre->nombre, ptrRecorre->anoIngreso, ptrRecorre->montoCuenta);
		ptrRecorre=ptrRecorre->siguiente;
	}
 
	fflush(stdin);
	getch();
}
 
//elimina lista tipo Pila
void eliminar_lista()
{
	struct agenda *ptrRecorre/*, siguiente*/;
 
	if (ptrPrimero!=NULL)
	{
		ptrRecorre = ptrPrimero;
 
		if (ptrRecorre->siguiente!=NULL)
			ptrPrimero=ptrRecorre->siguiente;
		else
			ptrPrimero=NULL;
 
		printf( "\n\t\t Se elimino el contacto %s!\n",ptrRecorre->nombre );
		free(ptrRecorre);
	}
	else
		printf( "\n\t\tNo existen contactos!\n" );
 
	fflush(stdin);
	getch();
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Correcion en C++

Publicado por Mauricio (4 intervenciones) el 26/11/2018 19:13:48
Claro, entonces que decís que es..
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar