Escolar Documentos
Profissional Documentos
Cultura Documentos
APLICACIONES
if (vector[i]<vector[j]){
valMenor=vector[i];
vector[i]=vector[j];
vector[j]=valMenor;
}
}
}
cout<<"===================="<<endl;
cout<<"Vector ordenado descendentemente:"<<endl;
for (int i = 0; i < cantElem; i++){
cout<<"Elemento["<<i+1<<"]="<<vector[i]<<endl;
}
//HALLANDO LOS ELEMENTOS REPETIDOS
int elemRep[MAX],contRep[MAX],cont=0,p=0,a=0;
for (int i = 0; i < cantElem-1; i++){
if (vector[i]==vector[i+1]){
cont=cont+1;
if (cont>0){
p=a;
contRep[p]=cont;
}
if (cont==1){
elemRep[p]=vector[i];
}
}
else{
if(cont>0) {
cont=0;
a=a+1;
}
}
}
cout<<"============================="<<endl;
float sumaR=0,promedio,sumaV=0,promedioV;
for (int i = 0; i < cantElem; i++){
sumaV+=vector[i];
}
if (contRep[0]<10000){
cin>>num;
while( num<=1 || num>20 || num % 2 != 0){
cout<<" Ingrese valor par y menor o igual a 20 : "<<endl;
cin>>num;}
cout<<" Ingresar datos de la matriz : "<<endl;
for(int i = 0 ; i<num;i++){
for(int j=0 ; j<num ; j++){
cout<<" ["<<i+1<<"]["<<j+1<<"]= ";
cin>>matriz[i][j];
}
}
//Lectura de Datos Ingresados
cout<<" Datos ingresados fueron :"<<endl<<endl;
for(int i = 0 ;i<num;i++){
for(int j = 0;j<num;j++){
cout<<" "<<matriz[i][j]<<" ";
}
cout<<" "<<endl<<endl;
}
//Diagonal Principal Ordenado Ascendente
for(int i = 0 ; i<num;i++){
for(int j= i + 1 ; j<num ; j++){
if(matriz[i][i]>matriz[j][j]){
temp = matriz[i][i];
matriz[i][i]=matriz[j][j];
matriz[j][j]=temp;
}
}
}
//Lectura Diagonal Secundaria
int diagl[20];
for(int i = 0 ;i<num;i++){
for(int j = 0;j<num;j++){
if(i+j==num-1){
diagl[i]=matriz[i][j];
cont = cont + 1;
break;
}
}
}
// Diagonal Menor Ordenado Ascendente
for(int i = 0;i<cont;i++){
for(int j = i+1;j<cont;j++){
if(diagl[i]<diagl[j]){
temp=diagl[i];
diagl[i]=diagl[j];
diagl[j]=temp;
}
}
}
//Ingresando nuevamente la cadena a la matriz
for(int i = 0 ;i<num;i++){
for(int j= 0;j<num;j++){
if(i+j==num-1){
matriz[i][j]=diagl[i];
}
}
}
//Lectura de Elementos Repetidos
for(int i = 0;i<num;i++){
for(int j=0;j<num;j++){
if(matriz[i][i]==matriz[j][num-1-j]){
cont2 = cont2 + 1 ;
}
}
}
//Impresion de Nueva Matriz
cout<<"La nueva matriz es : "<<endl<<endl<<endl;
for(int i = 0 ;i<num;i++){
for(int j = 0;j<num;j++){
cout<<" "<<matriz[i][j]<<" ";
}
cout<<" "<<endl<<endl;
}
//Impresion de Elementos Repetidos
cout<<" Numeros de elementos repetidos : "<<cont2<<endl;
system("PAUSE");
return 0 ;
else
{mayor=elemento2;}
if (elemento3>mayor)
{mayor=elemento3;}
if (elemento4>mayor)
{mayor=elemento4;}
if (elemento5>mayor)
{mayor=elemento5;}
//PARA HALLAR EL MENOR CON COMPARACIONES
SECUENCIALES
if(elemento1<elemento2)
{menor=elemento1;}
else
{menor=elemento2;}
if (elemento3<menor)
{menor=elemento3;}
if (elemento4<menor)
{menor=elemento4;}
if (elemento5<menor)
{menor=elemento5;}