Dev - C++ - Ayuda en C++

 
Vista:
sin imagen de perfil

Ayuda en C++

Publicado por Nael (9 intervenciones) el 04/05/2022 05:57:12
Estoy comenzando podrían ayudarme?

Captura-de-pantalla-2022-05-02-221611
Captura-de-pantalla-2022-05-02-221719
3
4
5
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++

Ayuda en C++

Publicado por Alfil (1444 intervenciones) el 04/05/2022 14:48:21
Queda algún pequeño detalle pendiente, dejo que lo averigües.

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
#include <iostream>
 
using namespace std;
 
struct Estudiante
{
    char nombre[30];
    char apellido[30];
    int notas[3];
    float promedio;
};
 
void menu();
void registrar(Estudiante v[], int &id);
void nota(Estudiante v[], int &id);
void consultar(Estudiante v[], int &id);
void listar(Estudiante v[], int &id);
 
int main()
{
    Estudiante e[100];
    int count = 0;
    char opcion;
 
    do {
        menu();
        cin >> opcion;
        cout << endl;
 
        switch (opcion)
        {
            case '1':
                registrar(e, count);
                break;
 
            case '2':
                nota(e, count);
                break;
 
            case '3':
                consultar(e, count);
                break;
 
            case '4':
                listar(e, count);
                break;
 
            case '5':
                cout << "FIN DEL PROGRAMA" << endl;
                break;
 
            default:
                cout << "OPCION NO VALIDA" << endl;
                break;
        }
 
    } while (opcion != '5');
 
    return 0;
}
 
void menu()
{
    cout << endl;
    cout << "     MENU PRINCIPAL"       << endl;
    cout << "=========================" << endl;
    cout << "1.- Registrar Estudiante"  << endl;
    cout << "2.- Registrar Nota"        << endl;
    cout << "3.- Consultar Estudiante"  << endl;
    cout << "4.- Listar Estudiantes"    << endl;
    cout << "5.- Salir"                 << endl;
    cout << "=========================" << endl;
    cout << "OPCION: ";
}
 
void registrar(Estudiante v[], int &id)
{
    cout << endl;
    cout << "Registro de Estudiantes" << endl << endl;
    cout << "Estudiante No " << id + 1 << endl << endl;
    cout << "Nombre: "; cin >> v[id].nombre;
    cout << "Apellido: "; cin >> v[id].apellido;
    cout << endl;
    cin.ignore(80, '\n');
 
    id++;
}
 
void nota(Estudiante v[], int &id)
{
    int numero, nota;
 
    cout << endl;
    cout << "Registro de Notas: " << endl << endl;
    cout << "Numero de Estudiante: "; cin >> numero;
 
    if (numero > id)
    {
        cout << "El Estudiante " << numero << " NO Existe" << endl;
        cout << "Numero Maximo de Estudiante " << id << endl;
    }
    else
    {
        cout << "Nombre: " << v[numero - 1].nombre << endl;
        cout << "Apellido: " << v[numero - 1].apellido << endl << endl;
        cout << "Nota a Introducir (1 - 3): "; cin >> nota;
        cout << "Nota: "; cin >> v[numero - 1].notas[nota - 1];
    }
}
 
void consultar(Estudiante v[], int &id)
{
    int numero;
 
    cout << endl;
    cout << "Consultar Estudiante: " << endl << endl;
    cout << "Numero de Estudiante: "; cin >> numero;
 
    if (numero > id)
    {
        cout << "El Estudiante " << numero << " NO Existe" << endl;
        cout << "Numero Maximo de Estudiante " << id << endl;
    }
    else
    {
        cout << "Nombre: " << v[numero - 1].nombre << endl;
        cout << "Apellido: " << v[numero - 1].apellido << endl << endl;
        cout << "Nota 1: " << v[numero - 1].notas[0] << endl;
        cout << "Nota 2: " << v[numero - 1].notas[1] << endl;
        cout << "Nota 3: " << v[numero - 1].notas[2] << endl << endl;
 
        v[numero - 1].promedio = (v[numero - 1].notas[0] + v[numero - 1].notas[1] + v[numero - 1].notas[2]) / 3.0f;
        cout << "Promedio Notas: " << v[numero - 1].promedio << endl;
    }
}
 
void listar(Estudiante v[], int &id)
{
    cout << endl;
    cout << "Listado de Estudiantes: " << endl << endl;
    cout << "Nombre  Apellido  Promedio" << endl << endl;
    for (int i = 0; i < id; i++)
    {
        cout << v[i].nombre << " " << v[i].apellido << " "<< v[i].promedio << endl;
    }
    cout << endl;
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil

Ayuda en C++

Publicado por Juan (2 intervenciones) el 09/12/2022 05:31:16
Me gusto ese programa cual era el pequeño detalle por arreglar?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar