estructuras y arreglos

la leyenda

Lanero Novato
15 Ago 2011
0
yo he creado un arreglo tipo estructura en donde el usuario es el que digita el tamaño del arreglo pero el programa no esta funcionando correctamente necesito que me ayuden por favor
#include <iostream>
#include <iomanip>
#include <string.h>
using namespace std;
struct estudiante
{
char Mat[15],Nom[40];
char Car[45];
double Ind;
};
struct dato
{
char Mater[25];
int Cred,Nf;
};
struct alumno
{
estudiante n;//ESTRUCTURAS ANIDADAS
dato V[5];//ESTRUCTURAS ANIDADAS
char Equiv[5];
int T[5];
};
void Entrada(struct alumno b[]);
void Calcular(struct alumno s[]);
void salida(struct alumno m[]);
int k;
int main()
{
cout<<"Digite la cantidad de estudiantes que desea registrar:";
cin>>k;
alumno p[]={k};//se crea un vector del tipo (alumno) para accede a cada campo de las demas estructuras
Entrada(p);// y para almacenar en el la informacion obtenida
system("pause");
return 0;
}
void Entrada(struct alumno b[])
{
for(int c=0;c<k;c++)
{
cout<<"\nDigite su matricula: ";
fflush(stdin);
cin.getline(b[c].n.Mat,sizeof(b[c].n.Mat));//para acceder a cada campo de las estructuras se utilisa el operador punto(.).
cout<<"\nDigite su nombre: ";
fflush(stdin);
cin.getline(b[c].n.Nom,sizeof(b[c].n.Nom));
cout<<"\nDigite el nombre de su carrera: ";
fflush(stdin);
cin.getline(b[c].n.Car,sizeof(b[c].n.Car));
system("cls");
for(int x=0;x<5;x++)
{
cout<<"\nDigite el nombre de sus asignaturas "<<endl;
fflush(stdin);//Se utiliza para liberar la memoria
cin.getline(b[c].V[x].Mater,sizeof(b[c].V[x].Mater));
cout<<"\nDigite la cantidad de creditos de esta asignatura: ";
cin>>b[c].V[x].Cred;
while(b[c].V[x].Cred<1 || b[c].V[x].Cred>6)
{
cout<<"\nHas sobrepasado el limite de creditos\n";
cout<<"Favor de digitar de nuevo sus creditos: ";
cin>>b[c].V[x].Cred;
}
cout<<"\nDigite la nota final de esta asignatura: ";
cin>>b[c].V[x].Nf;
while(b[c].V[x].Nf<0 || b[c].V[x].Nf>100)
{
cout<<"\nEstas digitando notas fuera de rango\n";
cout<<"Favor de digitar de nuevo su nota: ";
cin>>b[c].V[x].Nf;
}
}
system("cls");
}
Calcular(b);
}
void Calcular(struct alumno s[])
{
float Sumcred=0,puntos=0;
int f=0,l=0;
for(int c=0;c<k;c++)
{
for(int d=0;d<5;d++)
{
Sumcred+=s[c].V[d].Cred;
}
for(int d=0;d<5;d++)
{
if(s[c].V[d].Nf>=90 && s[c].V[d].Nf<=100)
{
s[c].Equiv[d]='A';
puntos=puntos+(s[c].V[d].Cred*4);
}
else
if(s[c].V[d].Nf>=80 && s[c].V[d].Nf<=89)
{
s[c].Equiv[d]='B';
puntos=puntos+(s[c].V[d].Cred*3);
}
else
if(s[c].V[d].Nf>=70 && s[c].V[d].Nf<=79)
{
s[c].Equiv[d]='C';
puntos=puntos+(s[c].V[d].Cred*2);
}
else
if(s[c].V[d].Nf>=60 && s[c].V[d].Nf<70)
{
s[c].Equiv[d]='D';
puntos=puntos+(s[c].V[d].Cred*1);
}
else
if(s[c].V[d].Nf<60 && s[c].V[d].Nf>=0)
{
s[c].Equiv[d]='F';
puntos=puntos+(s[c].V[d].Cred*0);
}
l=strlen(s[c].V[d].Mater); s[c].T[f]=l;
f++;
}
s[c].n.Ind=(puntos/Sumcred);
puntos=0; Sumcred=0; f=0;
}
salida(s);
}
void salida(struct alumno m[])
{
const int l=23;
for(int e=0;e<k;e++)
{
cout<<"\nMatricula: "<<m[e].n.Mat<<endl;
cout<<"\nNombre: "<<m[e].n.Nom<<endl;
cout<<"\nCarrera: "<<m[e].n.Car<<endl;
cout<<"\n\nAsignaturas\t\tCreditos\tNota Final\tEquivalencia"<<endl;
cout<<setfill('.');
for(int i=0;i<5;i++)
{
cout<<endl<<m[e].V.Mater;
switch(m[e].T)
{
case 24:{
cout<<setw(5)<<m[e].V.Cred;
break;}
case 23:{
cout<<setw((l-23)+5)<<m[e].V.Cred;
break;}
case 22:{
cout<<setw((l-22)+5)<<m[e].V.Cred;
break;}
case 21:{
cout<<setw((l-21)+5)<<m[e].V.Cred;
break;}
case 20:{
cout<<setw((l-20)+5)<<m[e].V.Cred;
break;}
case 19:{
cout<<setw((l-19)+5)<<m[e].V.Cred;
break;}
case 18:{
cout<<setw((l-18)+5)<<m[e].V.Cred;
break;}
case 17:{
cout<<setw((l-17)+5)<<m[e].V.Cred;
break;}
case 16:{
cout<<setw((l-16)+5)<<m[e].V.Cred;
break;}
case 15:{
cout<<setw((l-15)+5)<<m[e].V.Cred;
break;}
case 14:{
cout<<setw((l-14)+5)<<m[e].V.Cred;
break;}
case 13:{
cout<<setw((l-13)+5)<<m[e].V.Cred;
break;}
case 12:{
cout<<setw((l-12)+5)<<m[e].V.Cred;
break;}
case 11:{
cout<<setw((l-11)+5)<<m[e].V.Cred;
break;}
case 10:{
cout<<setw((l-10)+5)<<m[e].V.Cred;
break;}
case 9:{
cout<<setw((l-9)+5)<<m[e].V.Cred;
break;}
case 8:{
cout<<setw((l-8)+5)<<m[e].V.Cred;
break;}
case 7:{
cout<<setw((l-7)+5)<<m[e].V.Cred;
break;}
case 6:{
cout<<setw((l-6)+5)<<m[e].V.Cred;
break;}
case 5:{
cout<<setw((l-5)+5)<<m[e].V.Cred;
break;}
case 4:{
cout<<setw((l-4)+5)<<m[e].V.Cred;
break;}
case 3:{
cout<<setw((l-3)+5)<<m[e].V.Cred;
break;}
case 2:{
cout<<setw((l-2)+5)<<m[e].V.Cred;
break;}
}
cout<<setw(18)<<m[e].V.Nf;
cout<<setw(17)<<m[e].Equiv;
}
cout<<setprecision(2);
cout<<"\n\nIndice Acumulado: "<<m[e].n.Ind<<endl<<endl<<endl;
}
}
 

Los últimos temas