Dev - C++ - MENU PRINCIPAL Y SUB MENU: COMO PUEDO INCORPORAR UN SUB MENU, CON MAS OPCIONES

 
Vista:

MENU PRINCIPAL Y SUB MENU: COMO PUEDO INCORPORAR UN SUB MENU, CON MAS OPCIONES

Publicado por Francisco Ortiz ordoñez (1 intervención) el 01/10/2020 05:42:43
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
#include <iostream>
#include <cstdlib>
#include <conio.h>
 
using namespace std;
 
void pausa();
 
int main()
{
    bool bandera=false;
    char tecla;
 
    do
    {
        system("cls");
        cin.clear();
        cout << "MENU PRINCIPAL" << endl;
        cout << "-----------" << endl << endl;
        cout << "\t1 .- PERMUTACION" << endl;
        cout << "\t2 .- COMBINACION" << endl;
        cout << "\t3 .- Salir" << endl << endl;
        cout << "Elije una opcion: ";
 
        cin >> tecla;
 
		switch(tecla)
		{
			case '1':
				system("cls");
				cout << "HAS ELEGIDO PERMUTACION.\n";
				pausa();
				break;
 
			case '2':
				system("cls");
				cout << "HAS ELEGIDO COMBINACION.\n";
				pausa();
				break;
 
			case '3':
				bandera=true;
				break;
 
			default:
				system("cls");
				cout << "Opcion no valida.\a\n";
				pausa();
				break;
		}
    }while(bandera!=true);
 
    return 0;
}
 
void pausa()
{
    cout << "Pulsa una tecla para continuar...";
    getwchar();
    getwchar();
}
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
Imágen de perfil de Alfil
Val: 4.344
Oro
Ha mantenido su posición en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

MENU PRINCIPAL Y SUB MENU: COMO PUEDO INCORPORAR UN SUB MENU, CON MAS OPCIONES

Publicado por Alfil (1444 intervenciones) el 01/10/2020 21:26:21
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
#include <iostream>
 
using namespace std;
 
void menu();
void submenuUno();
void submenuDos();
 
int main()
{
    char opcion;
 
    do {
        menu();
        cin >> opcion;
 
        switch(opcion)
        {
            case '1':
                submenuUno();
                break;
 
            case '2':
                submenuDos();
                break;
 
            case '3':
                cout << "\n\nFIN DEL PROGRAMA" << endl;
                break;
 
            default:
                cout << "\n\nOPCION NO VALIDA" << endl;
                break;
        }
 
    }while (opcion != '3');
 
    return 0;
}
 
void menu()
{
    cout << "\n  MENU PRINCIPAL" << endl;
    cout << "==================" << endl;
    cout << "1 .- PERMUTACION" << endl;
    cout << "2 .- COMBINACION" << endl;
    cout << "3 .- Salir" << endl;
    cout << "==================" << endl;
    cout << "Elije una opcion: ";
}
 
void submenuUno()
{
    char opcion;
 
    do {
        cout << "\n  SUBMENU PERMUTACION" << endl;
        cout << "========================" << endl;
        cout << "1 .- Uno" << endl;
        cout << "2 .- Dos" << endl;
        cout << "3 .- Menu Principal" << endl;
        cout << "=======================" << endl;
        cout << "Elije una opcion: ";
 
        cin >> opcion;
 
        switch(opcion)
        {
            case '1':
                cout << "\nUNO\n";
                break;
 
            case '2':
                cout << "\nDOS\n";
                break;
 
            case '3':
                break;
 
            default:
                cout << "\n\nOPCION NO VALIDA" << endl;
                break;
        }
 
    } while (opcion != '3');
}
 
void submenuDos()
{
    char opcion;
 
    do {
        cout << "\n  SUBMENU COMBINACION" << endl;
        cout << "========================" << endl;
        cout << "1 .- Uno" << endl;
        cout << "2 .- Dos" << endl;
        cout << "3 .- Menu Principal" << endl;
        cout << "=======================" << endl;
        cout << "Elije una opcion: ";
 
        cin >> opcion;
 
        switch(opcion)
        {
            case '1':
                cout << "\nUNO\n";
                break;
 
            case '2':
                cout << "\nDOS\n";
                break;
 
            case '3':
                break;
 
            default:
                cout << "\n\nOPCION NO VALIDA" << endl;
                break;
        }
 
    } while (opcion != '3');
}
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