Vous êtes sur la page 1sur 3

#include<iostream>

#include<time.h>
using namespace std;
struct notas
{
float teoria;
float lab;
float tra;

}nota;
struct dat
{
char nombre[5];
char sexo[2];
struct notas nota;
float promedio;
}alum[7];

int main()
{
int ale,menor,men=0,c=0,p;
float q=0,r=0;
char axa[5],s[10],t[10];

srand(time(NULL));
struct dat;
struct notas;

for (int i = 0; i < 6; i++)


{
fflush(stdin);
cout<<"Ingresar nombre: ";
cin.getline(alum[i].nombre, 5);
//numero aleatorio
ale=rand()%3;
if (ale%2==0)
{
alum[i].sexo[0]='M';
}
else
{
alum[i].sexo[0]='F';
}
//notas
alum[i].nota.lab=rand()%20;
alum[i].nota.teoria=rand()%20;
alum[i].nota.tra=rand()%20;
//prom

alum[i].promedio=(2*alum[i].nota.lab+3*alum[i].nota.teoria+alum[i].nota.tr
a)/6;
}

for (int i = 0; i < 6; i++)


{
cout<<"nombre: "<<alum[i].nombre<<endl;
cout<<"Su sexo es: "<<alum[i].sexo[0]<<endl;
cout<<"nota laboratorio"<<alum[i].nota.lab<<endl;
cout<<"nota teoria"<<alum[i].nota.teoria<<endl;
cout<<"nota trabajo"<<alum[i].nota.tra<<endl;
cout<<"promedio: "<<alum[i].promedio<<endl;
cout<<"==============="<<endl;

//promedios
menor=alum[0].promedio;
for (int i = 0; i < 6; i++)
{
if (alum[i].promedio<menor)
{
menor=menor=alum[i].promedio;
men=i;
}
}
cout<<"El menor promedio es: "<<menor<<endl;
cout<<"Y corresponde a "<<alum[men].nombre<<endl;

//mejres nota aprobatoria


cout<<"Las mujeres con nota aprobatoria son: "<<endl;
for (int i = 0; i < 6; i++)
{
if (alum[i].sexo[0]=='F')
{
if (10.5<alum[i].promedio)
{

cout<<alum[i].nombre<<endl;
c++;
}
}
}
cout<<"Y son(cantidad): "<<c<<endl;
//orden de merito
for (int i = 0; i < 6; i++)
{
for (int j = i; j < 6; j++)
{
if (alum[i].nombre[0]>alum[j].nombre[0])
{
strcpy(axa,alum[i].nombre);
strcpy(alum[i].nombre,alum[j].nombre);
strcpy(alum[j].nombre,axa);

strcpy(s,alum[i].sexo);
strcpy(t,alum[j].sexo);
strcpy(alum[i].sexo,t);
strcpy(alum[j].sexo,s);

r=alum[i].promedio;
q=alum[j].promedio;
alum[i].promedio=q;
alum[j].promedio=r;

}
}
}
cout<<"\nOrdenamiento en orden alfabetico: "<<endl;
for(int i = 0; i < 6; i++)
{
cout<<"nombre: "<<alum[i].nombre<<endl;
cout<<"Su sexo es: "<<alum[i].sexo[0]<<endl;
cout<<"promedio: "<<alum[i].promedio<<endl;
}

//orden de merito
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 6; j++)
{
if (alum[i].promedio>alum[j].promedio&&i!=j)
{
r=alum[i].promedio;
q=alum[j].promedio;
alum[i].promedio=q;
alum[j].promedio=r;

strcpy(axa,alum[i].nombre);
strcpy(alum[i].nombre,alum[j].nombre);
strcpy(alum[j].nombre,axa);
}
}
}
cout<<"\n\norden de merito"<<endl<<endl;
for(int i = 0; i < 6; i++)
{
cout<<"nombre: "<<alum[i].nombre<<endl;
cout<<"promedio: "<<alum[i].promedio<<endl;
}

system("pause>null");
}

Vous aimerez peut-être aussi