Está en la página 1de 3

/*

//Una structura basica


#include<iostream>
#include<stdlib.h>
#include<string>
using namespace std;
struct tabla1{
char nombre[20];
int edad;
char curso[20];
int nota1,nota2,nota3,nota4;

};
void main(){
tabla1 T1;

cout<<"Ingrese el Nombre= ";


cin.getline(T1.nombre,20);
cout<<"Ingrese la edad= ";
cin>>T1.edad;
cout<<"Ingrese el Curso= ";cin.ignore();
cin.getline(T1.curso,20);
cout<<"Ingrese las Notas= "<<endl
<<"Ingrese la nota 1= ";
cin>>T1.nota1;
cout<<"Ingrese Nota 2= "<<endl;
cin>>T1.nota2;
cout<<"Ingrese Nota 3= "<<endl;
cin>>T1.nota3;
cout<<"Ingrese Nota 4= "<<endl;
cin>>T1.nota4;
float promedio;
promedio=(T1.nota1+T1.nota2+T1.nota3+T1.nota4)/4.0;

system("pause");
cout<<"Mostar el Registro "<<endl
<<"El Alumno de Nombre= "<<T1.nombre<<endl
<<"De edad= "<<T1.edad<<endl
<<"Curso= "<<T1.curso<<endl
<<"Tiene de notas=nota1 "<<T1.nota1<<endl
<<"Nota 2= "<<T1.nota2<<endl
<<"Nota 3= "<<T1.nota3<<endl
<<"Nota 4= "<<T1.nota4<<endl
<<"Su promedio sin considerar la menor= "<<endl
<<promedio<<endl;
system("pause");
}
*/
//Usando un arreglo
//Una structura basica
#include<iostream>
#include<stdlib.h>
#include<string>
using namespace std;
struct tabla1{
char nombre[20];
int edad;
char curso[20];
int nota1,nota2,nota3,nota4;

};
float promedio;//variable publica
void main(){
tabla1 T1[100];//Creando un arreglo de objetos
int N;
cout<<"Ingrese el Numero de Registros= ";
cin>>N;
for(int i=1;i<=N;i++){
cout<<"Ingrese el Nombre= ";cin.ignore();
cin.getline(T1[i].nombre,20);
cout<<"Ingrese la edad= ";
cin>>T1[i].edad;
cout<<"Ingrese el Curso= ";cin.ignore();
cin.getline(T1[i].curso,20);
cout<<"Ingrese las Notas= "<<endl
<<"Ingrese la nota 1= ";
cin>>T1[i].nota1;
cout<<"Ingrese Nota 2= "<<endl;
cin>>T1[i].nota2;
cout<<"Ingrese Nota 3= "<<endl;
cin>>T1[i].nota3;
cout<<"Ingrese Nota 4= "<<endl;
cin>>T1[i].nota4;

promedio=(T1[i].nota1+T1[i].nota2+T1[i].nota3+T1[i].nota4)/4.0;
}

system("pause");
cout<<"Mostar los Registros "<<endl;
for(int i=1;i<=N;i++){
cout<<"El Alumno de Nombre= "<<T1[i].nombre<<endl
<<"De edad= "<<T1[i].edad<<endl
<<"Curso= "<<T1[i].curso<<endl
<<"Tiene de notas=nota1 "<<T1[i].nota1<<endl
<<"Nota 2= "<<T1[i].nota2<<endl
<<"Nota 3= "<<T1[i].nota3<<endl
<<"Nota 4= "<<T1[i].nota4<<endl
<<"Su promedio sin considerar la menor= "<<endl
<<promedio<<endl;
}
system("pause");
}

También podría gustarte