Problema al imprimir datos de un registro
Publicado por Pedro Manuel (2 intervenciones) el 18/09/2020 19:07:40
Buenos días, tardes o noches, me he encontrado con un problema en el cual no encuentro solución. Se trata de que al momento de imprimir los datos de una estructura salen de manera incorrecta, dejaré el código y la foto respectiva y si alguien me puede ayudar estaré agradecido:
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 <iostream>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#include <ctype.h>
#include <stdio.h>
#include <iomanip>
#include <time.h>
#include <string.h>
using namespace std;
void gotoxy(int x,int y)
{
static HANDLE h = NULL;
if(!h)
h = GetStdHandle(STD_OUTPUT_HANDLE);
COORD c = { x,y };
SetConsoleCursorPosition(h,c);
}
struct Corredor
{
char Nombre[20];
int edad;
char Sexo[20];
char Club[20];
};
int main()
{
gotoxy(15,2);cout<<"* * * * * * * * * * * * * * * * * * * *";
gotoxy(15,3);cout<<"CAPITULO II";
gotoxy(15,4);cout<<"*=====================================*";
gotoxy(15,5);cout<<"ESTRUCTURA DE DATOS";
gotoxy(15,6);cout<<"*=====================================*";
gotoxy(15,7);cout<<"TEMA";
gotoxy(15,8);cout<<"*=====================================*";
gotoxy(15,9);cout<<"REGISTROS (ESTRUCTURAS)";
gotoxy(15,10);cout<<"*=====================================*";
gotoxy(15,11),cout<<"EJEMPLO 01";
gotoxy(15,12);cout<<"*=====================================*";
gotoxy(15,13);cout<<"HACER UNA ESTRUCTURA, PEDIR DATOS AL";
gotoxy(15,14);cout<<"USUARIO, IMPRIMIR TODOS LAS DATOS Y";
gotoxy(15,15);cout<<"LA CATEGORIA DE LA COMPETICION.";
gotoxy(15,16);cout<<"* * * * * * * * * * * * * * * * * * * *";
gotoxy(1,20);cout<<"PRESIONE <ENTER> PARA CONTINUAR";
getch();
system("cls");
int n;
char categoria[20];
Corredor c[n];
cout<<"\nINGRESE EL NUMERO DE CONCURSANTES: ";cin>>n;
for(int i=0; i<n; i++)
{
cout<<"\nCONCURSANTE NUMERO "<<i+1<<" :";
fflush(stdin);
cout<<"\nNOMBRE: "; cin.getline(c[i].Nombre,20,'\n');
fflush(stdin);
cout<<"\nEDAD: "; cin>>c[i].edad;
fflush(stdin);
cout<<"\nSEXO: "; cin.getline(c[i].Sexo,20,'\n');
fflush(stdin);
cout<<"\nCLUB: "; cin.getline(c[i].Club,20,'\n');
fflush(stdin);
if(c[i].edad <= 18)
{
strcpy(categoria,"Juvenil");
}
else if(c[i].edad <= 40 && c[i].edad >=19)
{
strcpy(categoria,"Senior");
}
else
{
strcpy(categoria,"Veterano");
}
}
cout<<"\n\nMostrando Datos"<<endl;
for(int i=0; i<n; i++)
{
fflush(stdin);
cout<<"\nCONCURSANTE NUMERO "<<i+1<<" :"<<endl;
cout<<"Nombre: "<<c[i].Nombre<<endl;
fflush(stdin);
cout<<"Edad: "<<c[i].edad<<endl;
fflush(stdin);
cout<<"Sexo: "<<c[i].Sexo<<endl;
fflush(stdin);
cout<<"Club: "<<c[i].Club<<endl;
fflush(stdin);
cout<<"Categoria: "<<categoria<<endl;
cout<<"\n";
}
getch();
return 0;
}
Valora esta pregunta
0