int main(){ SecuenciaEnteros secuencia; secuencia.Aniade(2); secuencia.Aniade(4); secuencia.Aniade(1); secuencia.Aniade(1); secuencia.Aniade(7); secuencia.Aniade(2); secuencia.Aniade(1); cout << "\nHay " << secuencia.NumeroSecuencias() << " secuencias."; cout << "\n\n"; }
SecuenciaEnteros RecuperaFila(int n){ SecuenciaEnteros fila; for(int i; i < columnas_util; i++){ fila.Aniade(Elemento(n, i)); } return fila; }
int main(){ SecuenciaEnteros entero; int enterillo; const int TERMINADOR = 0; cout << "Introduzca un entero: "; cin >> enterillo; while (enterillo != TERMINADOR){ entero.Aniade(enterillo); cout << "\nIntroduzca otro: "; cin >> enterillo; } cout << "\n\nSe han introducido " << entero.SecuenciasAscendentes() << " secuencias en forma ascendente."; }
int main(){ int numero; MatrizRectangularEnteros matriz, matriz1; SecuenciaEnteros fila; int cuantos; bool son_iguales; cout << "\n\nIntroduce el numero de filas: "; cin >> cuantos; for(int i = 1; i <= cuantos; i++){ cout << "\n\nIntroduce una fila (-1 para terminar): "; while( numero != -1){ cin >> numero; if (numero != -1){ fila.Aniade(numero); } } matriz.AniadeFila(fila); fila.Inicializa(); numero = 0; } cout << endl << endl; cout << "\n\nD A T O S M A T R I Z P R I N C I P A L" << endl; for(int i = 0; i < matriz.GetFilas(); i++){ for(int j = 0; j < matriz.GetColumnas(); j++){ cout << matriz.Elemento(i, j); } cout << endl; } cout << "\n\n R E C U P E R A R F I L A"; cout << "\n\nfila a recuperar: "; cin >> numero; SecuenciaEnteros FilaR(matriz.RecuperaFila(numero)); for (int i = 0; i < FilaR.TotalUtilizados(); i++){ cout << FilaR.Elemento(i) << " "; } cout << "\n\nC O M P A R A C I O N D E M A T R I C E S" << endl; cout << "\n\nIntroduzca los datos de una segunda matriz a comparar: "; cout << "\n\nIntroduce el numero de filas: "; cin >> cuantos; for(int i = 1; i <= cuantos; i++){ cout << "\n\nIntroduce una fila (-1 para terminar): "; while( numero != -1){ cin >> numero; if (numero != -1){ fila.Aniade(numero); } } matriz1.AniadeFila(fila); fila.Inicializa(); numero = 0; } son_iguales = matriz.Compara(matriz1); if (son_iguales){ cout << "\n\nLas matrices son iguales"; } else{ cout << "\n\nLas matrices no son iguales"; } cout << "\n\n T R A N S P U E S T A D E L A P R I M E R A M A T R I Z" << endl; MatrizRectangularEnteros traspuesta(matriz.Traspuesta()); for(int i = 0; i < traspuesta.GetFilas(); i++){ for(int j = 0; j < traspuesta.GetColumnas(); j++){ cout << traspuesta.Elemento(i, j); } cout << endl; } cout << "\n\nC O M P R O B A C I O N S I M E T R I A"; son_iguales = matriz.Compara(traspuesta); if (son_iguales){ cout << "\n\nLas matrices son simétricas"; } else{ cout << "\n\nLas matrices no son simétricas"; } cout << "\n\nM E T O D O 2"; son_iguales = matriz.ComparaSimetrica(traspuesta); if (son_iguales){ cout << "\n\nLas matrices son simétricas"; } else{ cout << "\n\nLas matrices no son simétricas"; } cout << "\n\nM U L T I P L I C A C I O N" << endl; if (matriz.GetColumnas() == matriz1.GetFilas()){ MatrizRectangularEnteros operacion(matriz.Multiplica(matriz, matriz1)); //cout << "\n\n-->" << operacion.GetFilas() << " " << operacion.GetColumnas(); for(int i = 0; i < operacion.GetFilas(); i++){ for(int j = 0; j < operacion.GetColumnas(); j++){ cout << operacion.Elemento(i, j) << " "; } cout << endl; } } else{ cout << "\n\nLas matrices no pueden multiplicarse"; } cout << endl << endl; }