Anda di halaman 1dari 4

//Halla el promedio de edades, la edad mayor, edad menor

//oredena las edades


/*
#include<iostream>
#include<stdlib.h>
using namespace std;
void main(){
int Ed[100],N,i,j,M,m,indM,indm,tempo;
float S=0,prome;
cout<<"Ingrese el numero de Alumnos N= ";
cin>>N;
for(i=0;i<N;i++)
cin>>Ed[i];
M=Ed[0];
for(i=0;i<N;i++)
if(Ed[i]>=M){
M=Ed[i];
indM=i;
}

m=Ed[0];

for(i=0;i<N;i++)
if(Ed[i]<=m){
m=Ed[i];
indm=i;
}

for(i=0;i<N;i++)
S+=Ed[i];
prome=S*1.0/N;

for(i=0;i<N;i++)
for(j=i;j<N;j++)
if(Ed[i]>Ed[j]){
tempo=Ed[i];
Ed[i]=Ed[j];
Ed[j]=tempo;
} cout<<"Ordenado= ";
cout<<'[';
for(i=0;i<N;i++)
cout<<Ed[i]<<' ';
cout<<']';

cout<<"\nLa myor Nota= "<<M<<endl


<<"Esta ubicado en la posicion"<<(indM+1)<<endl
<<"La menor Nota= "<<m<<endl
<<"Esta ubicado en la posicion"<<(indm+1)<<endl
<<"El promedio= "<<prome<<endl;
system("pause");
}

//
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
void main(){
srand((unsigned)time(NULL));
int N,tink[50],i,yo;
cout<<"Ingrese el numero de valores N= ";
cin>>N;
for(i=0;i<N;i++)
tink[i]=rand()%6+1;
cout<<"Los valores generados= [";
for(i=0;i<N;i++)
cout<<tink[i]<<' ';
cout<<']';

yo=rand()%6+1;
cout<<"\nMi numero= "<<yo;

for(i=0;i<N;i++)
if(yo==tink[i])
cout<<"\nacerte ";
cout<<endl;
system("pause");
}

//
//Se han generado N notas aleatorias de un curso se pide
//realizar las siguientes operaciones
//Mostrar las Notas Generadas
//La Mayor Nota
//La menor Nota
//Ordenando las Nptas
//Visualizarlas
//Cuantas Notas Superan al Promedio

#include<iostream>
#include<stdlib.h>
#include<time.h>
#include<conio.h>
#include<ctype.h>
using namespace std;
void main(){
int N,M,m,nsp=0,aux,p,S=0,notas[100];
cout<<"Ingrese numero de elementos N = ";
cin>>N;
cout<<"Ingrse las Notas= ";
for(int i=0;i<N;i++)
cin>>notas[i];
M=notas[0];
for(int i=0;i<N;i++)
if(notas[i]>=M)
M=notas[i];

m=notas[0];
for(int i=0;i<N;i++)
if(notas[i]<=m)
m=notas[i];

for(int i=0;i<N;i++)
S=S+notas[i];
p=S*1.0/N;

for(int i=0;i<N;i++)
if(notas[i]>p)
nsp++;

for(int i=0;i<N;i++)
for(int j=i;j<N;j++)
if(notas[i]>=notas[j]){
aux=notas[i];
notas[i]=notas[j];
notas[j]=aux;
}
cout<<"\n las notas Ordenadas= ";
for(int i=0;i<N;i++)
cout<<notas[i]<<';';

cout<<"\nLa mayor Nota= "<<M<<endl


<<"La menor nota= "<<m<<endl
<<"El promedio= "<<p<<endl
<<"Notas que superan el promnedio "<<nsp<<endl;
system("pause");

//Se tienen las edades de 15 alumnos


//hallar la mayor edad, la menor edad, el promedio
//Ordenarlos ascendentemente
#include<iostream>
#include<stdlib.h>
using namespace std;
void main(){
int N,i,j,M,m,edad[100],indM,indm,tempo;
float S=0,promedio;
cout<<"Ingrese el numero de Alumnos= ";
cin>>N;
for(i=0;i<N;i++){
cout<<"Alumno "<<i<<"->";
cin>>edad[i];
}
M=edad[0];
for(i=0;i<N;i++)
if(edad[i]>M){
M=edad[i];
indM=i;
}
m=edad[0];

for(i=0;i<N;i++)
if(edad[i]<m){
m=edad[i];
indm=i;
}

for(i=0;i<N;i++)
S+=edad[i];
promedio=S*1.0/N;
// ordenando ascendentemente
//metodo de la burbuja
for(i=0;i<N;i++)
for(j=i;j<N;j++)
if(edad[i]>edad[j]){
tempo=edad[i];
edad[i]=edad[j];
edad[j]=tempo;
}
cout<<"Ordenado ascendentemente";
for(i=0;i<N;i++)
cout<<edad[i]<<' ';

cout<<"\nla mayor edad= "<<M<<"Se ubica en la posicion "<<indM<<endl


<<"La menor edad= "<<m<<"Se ubica en la posicion "<<indm<<endl
<<"El promedio= "<<promedio
<<endl;
system("pause");
}

*/
//matrices
#include<iostream>
#include<stdlib.h>
#include<time.h>
#include<iomanip>
using namespace std;
void main(){
srand((unsigned) time(NULL));
int N,i,j,A[50][50],fil,col;
cout<<"Ingrese el numero de filas= ";
cin>>fil;
cout<<"Ingrese el numero de columnas= ";
cin>>col;
for(i=0;i<fil;i++)
for(j=0;j<col;j++)
A[i][j]=rand()%21;
for(i=0;i<fil;i++){
for(j=0;j<col;j++){
cout<<setw(2)<<A[i][j]<<' ';}
cout<<endl;
}
system("pause");
}

//<<setw(2)

Anda mungkin juga menyukai