Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication5.cpp : main project file.
- #include "stdafx.h"
- #include <conio.h>
- #include <iostream>
- using namespace std;
- using namespace System;
- struct Alumno
- {
- int edad;
- char genero;
- float altura;
- };
- void Leer_Alumnos(Alumno * Arreglo, int n)
- {
- for (int i = 0; i < n; i++)
- {
- cout << "Ingrese la edad: ";
- cin >> Arreglo[i].edad;
- cout << "Ingrese el genero: ";
- cin >> Arreglo[i].genero;
- Arreglo[i].genero = toupper(Arreglo[i].genero);
- cout << "Ingrese la altura: ";
- cin >> Arreglo[i].altura;
- }
- }
- void Imprimir_Alumnos(Alumno*Arreglo, int n)
- {
- for (int i = 0; i < n; i++)
- {
- cout << Arreglo[i].edad << ' ' << Arreglo[i].genero << ' ' << Arreglo[i].altura << endl;
- }
- }
- void Ordenar_Estatura(Alumno*Arreglo, int n)
- {
- Alumno aux;
- for (int i = 0; i < n - 1; i++)
- {
- for (int j = i + 1; j < n;j++)
- {
- if (Arreglo[i].altura < Arreglo[j].altura)
- {
- aux = Arreglo[i];
- Arreglo[i] = Arreglo[j];
- Arreglo[j]= aux;
- }
- }
- }
- }
- void Imprime_Numero_Alumnos(Alumno*Arreglo, int n)
- {
- int CMas = 0;
- for (int i = 0; i < n; i++)
- {
- if (Arreglo[i].genero == 'M') CMas++;
- }
- cout << "Hay " << CMas << " alumnos " << (char)11 << '.'<<endl;
- }
- int main()
- {
- int n;
- cout << "Ingrese el numero de alumnos: ";
- cin >> n;
- Alumno *ArrAlu = new Alumno[n];
- Leer_Alumnos(ArrAlu, n);
- Imprimir_Alumnos(ArrAlu, n);
- Imprime_Numero_Alumnos(ArrAlu, n);
- Ordenar_Estatura(ArrAlu, n);
- Imprimir_Alumnos(ArrAlu, n);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment