Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- char vector[11];
- int matrizA[6][6];
- int matrizB[6][6];
- int matrizC[6][6];
- int matrizD[6][6];
- bool MenuA = false;
- bool MenuB = false;
- int x, y;
- void menua()
- {
- int opc = -1;
- do{
- system("cls");
- printf("1.- Captura de Datos\n");
- printf("2.- Consulta de Datos\n");
- printf("3.- Modificacion de Datos\n");
- printf("4.- Impresion de Datos\n");
- printf("Selecciona una Opcion: ");
- scanf("%i", &opc);
- if( opc != 1 && MenuA == false)
- {
- printf("Aun no has Ingresado los Datos al Vector\n");
- opc = -1;
- system("pause");
- }
- }while(opc < 1 || opc > 4);
- system("cls");
- if(opc == 1)
- {
- MenuA = true;
- printf("Captura de Datos\n");
- for(x = 1; x <= 10; x++)
- {
- fflush(stdin);
- printf("Posicion %i: ", x);
- scanf("%c", &vector[x]);
- }
- printf("Datos Capturados!\n");
- system("pause");
- }else if(opc == 2){
- printf("Consulta de Datos\n");
- fflush(stdin);
- char valor;
- printf("Valor a Buscar: ");
- scanf("%c", &valor);
- for(x = 1; x <= 10; x++)
- {
- if(vector[x] == valor)
- {
- printf("El Valor Capturado Existe en el Vector\n");
- system("pause");
- return;
- }
- }
- printf("El Valor Capturado no existe en el Vector\n");
- system("pause");
- }else if(opc == 3){
- printf("Modificacion de Datos\n");
- char valor, nuevo_valor;
- fflush(stdin);
- printf("Valor a Buscar: ");
- scanf("%c", &valor);
- fflush(stdin);
- printf("Nuevo Valor : ");
- scanf("%c", &nuevo_valor);
- bool existe = false;
- for(x = 1; x <= 10; x++)
- {
- if(vector[x] == valor)
- {
- existe = true;
- printf("Valor de la Posicion [%i] Cambiada\n", x);
- vector[x] = nuevo_valor;
- }
- }
- if(existe == true)
- {
- printf("Datos Cambiados\n");
- }else{
- printf("No se encontro el Valor a Reemplazar\n");
- }
- system("pause");
- }else if(opc == 4){
- printf("Impresion de Datos\n");
- for(x = 1; x <= 10; x++)
- {
- printf("Posicion %i Valor: %c\n", x, vector[x]);
- }
- system("pause");
- }
- }
- void menub()
- {
- int opc = -1;
- do{
- system("cls");
- printf("1.- Captura de Datos\n");
- printf("2.- Suma de Matrices\n");
- printf("3.- Multiplicacion de Matrices\n");
- printf("4.- Impresion de Matrices\n");
- printf("Selecciona una Opcion: ");
- scanf("%i", &opc);
- if( opc != 1 && MenuB == false )
- {
- opc = -1;
- printf("Aun no has Ingresado los Datos a la Matriz\n");
- system("pause");
- }
- }while(opc < 1 || opc > 4);
- system("cls");
- if(opc == 1)
- {
- MenuB = true;
- printf("Captura de Datos\n");
- printf("Matriz A\n");
- for(x = 1; x <= 5; x++)
- {
- for(y = 1; y <= 5; y++)
- {
- do{
- printf("Posicion [%i][%i]: ", x, y);
- scanf("%i", &matrizA[x][y]);
- }while(matrizA[x][y] < 0 || matrizA[x][y] > 100);
- }
- }
- printf("Matriz B\n");
- for(x = 1; x <= 5; x++)
- {
- for(y = 1; y <= 5; y++)
- {
- do{
- printf("Posicion [%i][%i]: ", x, y);
- scanf("%i", &matrizB[x][y]);
- }while(matrizB[x][y] < 0 || matrizB[x][y] > 100);
- }
- }
- printf("Datos Capturados\n");
- system("pause");
- }else if(opc == 2){
- printf("Suma de Matrices\n");
- for(x = 1; x <= 5; x++)
- {
- for(y = 1; y <= 5; y++)
- {
- printf("Posicion [%i][%i]: %i + %i \n", x, y, matrizA[x][y], matrizB[x][y]);
- matrizC[x][y] = matrizA[x][y] + matrizB[x][y];
- }
- }
- printf("Matrices Sumadas\n");
- system("pause");
- }else if(opc == 3){
- printf("Multiplicacion de Matrices\n");
- for(x = 1; x <= 5; x++)
- {
- for(y = 1; y <= 5; y++)
- {
- printf("Posicion [%i][%i]: %i * %i \n", x, y, matrizA[x][y], matrizB[x][y]);
- matrizD[x][y] = matrizA[x][y] * matrizB[x][y];
- }
- }
- printf("Matrices Multiplicadas\n");
- system("pause");
- }else if(opc == 4){
- printf("Impresion de Matrices\n");
- printf("Matriz A\n");
- for(x = 1; x <= 5; x++)
- {
- for(y = 1; y <= 5; y++)
- {
- printf("Posicion [%i][%i], Valor: %i \n", x, y, matrizA[x][y]);
- }
- }
- printf("\nMatriz B\n");
- for(x = 1; x <= 5; x++)
- {
- for(y = 1; y <= 5; y++)
- {
- printf("Posicion [%i][%i], Valor: %i \n", x, y, matrizB[x][y]);
- }
- }
- printf("\nMatriz C\n");
- for(x = 1; x <= 5; x++)
- {
- for(y = 1; y <= 5; y++)
- {
- printf("Posicion [%i][%i], Valor: %i \n", x, y, matrizC[x][y]);
- }
- }
- printf("\nMatriz D\n");
- for(x = 1; x <= 5; x++)
- {
- for(y = 1; y <= 5; y++)
- {
- printf("Posicion [%i][%i], Valor: %i \n", x, y, matrizD[x][y]);
- }
- }
- printf("\nMatrices Impresas\n");
- system("pause");
- }
- }
- int main()
- {
- char opc = 'd';
- do{
- system("cls");
- printf("A - Control de Vectores\n");
- printf("\t1.- Captura de Datos\n");
- printf("\t2.- Consulta de Datos\n");
- printf("\t3.- Modificacion de Datos\n");
- printf("\t4.- Impresion de Datos\n");
- printf("B - Contol de Matrices\n");
- printf("\t1.- Captura de Datos\n");
- printf("\t2.- Suma de Matrices\n");
- printf("\t3.- Multiplicacion de Matrices\n");
- printf("\t4.- Impresion de Matrices\n");
- printf("C - Fin del Programa\n");
- printf("Selecciona una Opcion: ");
- scanf("%c", &opc);
- switch(tolower(opc))
- {
- case 'a':
- menua();
- break;
- case 'b':
- menub();
- break;
- case 'c':
- break;
- default:
- printf("Opcion Invalida\n");
- break;
- }
- }while(tolower(opc) != 'c');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement