Advertisement
s00rk

Eduardo Proyecto

Dec 2nd, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.71 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. char vector[11];
  6. int matrizA[6][6];
  7. int matrizB[6][6];
  8. int matrizC[6][6];
  9. int matrizD[6][6];
  10. bool MenuA = false;
  11. bool MenuB = false;
  12. int x, y;
  13.  
  14. void menua()
  15. {
  16.     int opc = -1;
  17.     do{
  18.         system("cls");
  19.         printf("1.- Captura de Datos\n");
  20.         printf("2.- Consulta de Datos\n");
  21.         printf("3.- Modificacion de Datos\n");
  22.         printf("4.- Impresion de Datos\n");
  23.         printf("Selecciona una Opcion: ");
  24.         scanf("%i", &opc);
  25.         if( opc != 1 && MenuA == false)
  26.         {
  27.             printf("Aun no has Ingresado los Datos al Vector\n");
  28.             opc = -1;
  29.             system("pause");
  30.         }
  31.     }while(opc < 1 || opc > 4);
  32.    
  33.     system("cls");
  34.     if(opc == 1)
  35.     {
  36.         MenuA = true;
  37.         printf("Captura de Datos\n");
  38.         for(x = 1; x <= 10; x++)
  39.         {
  40.             fflush(stdin);
  41.             printf("Posicion %i: ", x);
  42.             scanf("%c", &vector[x]);
  43.         }
  44.         printf("Datos Capturados!\n");
  45.         system("pause");
  46.  
  47.     }else if(opc == 2){
  48.        
  49.         printf("Consulta de Datos\n");
  50.         fflush(stdin);
  51.         char valor;
  52.         printf("Valor a Buscar: ");
  53.         scanf("%c", &valor);
  54.         for(x = 1; x <= 10; x++)
  55.         {
  56.             if(vector[x] == valor)
  57.             {
  58.                 printf("El Valor Capturado Existe en el Vector\n");
  59.                 system("pause");
  60.                 return;
  61.             }
  62.         }
  63.         printf("El Valor Capturado no existe en el Vector\n");
  64.         system("pause");
  65.  
  66.     }else if(opc == 3){
  67.  
  68.         printf("Modificacion de Datos\n");
  69.         char valor, nuevo_valor;
  70.  
  71.         fflush(stdin);     
  72.         printf("Valor a Buscar: ");
  73.         scanf("%c", &valor);
  74.  
  75.         fflush(stdin);
  76.         printf("Nuevo Valor : ");
  77.         scanf("%c", &nuevo_valor);
  78.  
  79.         bool existe = false;
  80.  
  81.         for(x = 1; x <= 10; x++)
  82.         {
  83.             if(vector[x] == valor)
  84.             {
  85.                 existe = true;
  86.                 printf("Valor de la Posicion [%i] Cambiada\n", x);
  87.                 vector[x] = nuevo_valor;
  88.             }
  89.         }
  90.         if(existe == true)
  91.         {
  92.             printf("Datos Cambiados\n");
  93.         }else{
  94.             printf("No se encontro el Valor a Reemplazar\n");
  95.         }
  96.         system("pause");
  97.  
  98.     }else if(opc == 4){
  99.  
  100.         printf("Impresion de Datos\n");
  101.         for(x = 1; x <= 10; x++)
  102.         {
  103.             printf("Posicion %i Valor: %c\n", x, vector[x]);
  104.         }
  105.         system("pause");
  106.     }
  107. }
  108.  
  109. void menub()
  110. {  
  111.     int opc = -1;
  112.     do{
  113.         system("cls");
  114.         printf("1.- Captura de Datos\n");
  115.         printf("2.- Suma de Matrices\n");
  116.         printf("3.- Multiplicacion de Matrices\n");
  117.         printf("4.- Impresion de Matrices\n");
  118.         printf("Selecciona una Opcion: ");
  119.         scanf("%i", &opc);
  120.         if( opc != 1 && MenuB == false )
  121.         {
  122.             opc = -1;
  123.             printf("Aun no has Ingresado los Datos a la Matriz\n");
  124.             system("pause");
  125.         }
  126.     }while(opc < 1 || opc > 4);
  127.  
  128.     system("cls");
  129.     if(opc == 1)
  130.     {
  131.         MenuB = true;
  132.         printf("Captura de Datos\n");
  133.         printf("Matriz A\n");
  134.         for(x = 1; x <= 5; x++)
  135.         {
  136.             for(y = 1; y <= 5; y++)
  137.             {
  138.                 do{
  139.                     printf("Posicion [%i][%i]: ", x, y);
  140.                     scanf("%i", &matrizA[x][y]);
  141.                 }while(matrizA[x][y] < 0 || matrizA[x][y] > 100);
  142.             }
  143.         }
  144.         printf("Matriz B\n");
  145.         for(x = 1; x <= 5; x++)
  146.         {
  147.             for(y = 1; y <= 5; y++)
  148.             {
  149.                 do{
  150.                     printf("Posicion [%i][%i]: ", x, y);
  151.                     scanf("%i", &matrizB[x][y]);
  152.                 }while(matrizB[x][y] < 0 || matrizB[x][y] > 100);
  153.             }
  154.         }
  155.         printf("Datos Capturados\n");
  156.         system("pause");
  157.  
  158.     }else if(opc == 2){
  159.  
  160.         printf("Suma de Matrices\n");
  161.         for(x = 1; x <= 5; x++)
  162.         {
  163.             for(y = 1; y <= 5; y++)
  164.             {
  165.                 printf("Posicion [%i][%i]: %i + %i \n", x, y, matrizA[x][y], matrizB[x][y]);
  166.                 matrizC[x][y] = matrizA[x][y] + matrizB[x][y];
  167.             }
  168.         }
  169.         printf("Matrices Sumadas\n");
  170.         system("pause");
  171.  
  172.     }else if(opc == 3){
  173.  
  174.         printf("Multiplicacion de Matrices\n");
  175.         for(x = 1; x <= 5; x++)
  176.         {
  177.             for(y = 1; y <= 5; y++)
  178.             {
  179.                 printf("Posicion [%i][%i]: %i * %i \n", x, y, matrizA[x][y], matrizB[x][y]);
  180.                 matrizD[x][y] = matrizA[x][y] * matrizB[x][y];
  181.             }
  182.         }
  183.         printf("Matrices Multiplicadas\n");
  184.         system("pause");
  185.  
  186.     }else if(opc == 4){
  187.  
  188.         printf("Impresion de Matrices\n");
  189.  
  190.         printf("Matriz A\n");
  191.         for(x = 1; x <= 5; x++)
  192.         {
  193.             for(y = 1; y <= 5; y++)
  194.             {
  195.                 printf("Posicion [%i][%i], Valor: %i \n", x, y, matrizA[x][y]);
  196.             }
  197.         }
  198.  
  199.         printf("\nMatriz B\n");
  200.         for(x = 1; x <= 5; x++)
  201.         {
  202.             for(y = 1; y <= 5; y++)
  203.             {
  204.                 printf("Posicion [%i][%i], Valor: %i \n", x, y, matrizB[x][y]);
  205.             }
  206.         }
  207.  
  208.         printf("\nMatriz C\n");
  209.         for(x = 1; x <= 5; x++)
  210.         {
  211.             for(y = 1; y <= 5; y++)
  212.             {
  213.                 printf("Posicion [%i][%i], Valor: %i \n", x, y, matrizC[x][y]);
  214.             }
  215.         }
  216.  
  217.         printf("\nMatriz D\n");
  218.         for(x = 1; x <= 5; x++)
  219.         {
  220.             for(y = 1; y <= 5; y++)
  221.             {
  222.                 printf("Posicion [%i][%i], Valor: %i \n", x, y, matrizD[x][y]);
  223.             }
  224.         }
  225.  
  226.         printf("\nMatrices Impresas\n");
  227.         system("pause");
  228.  
  229.     }
  230. }
  231.  
  232. int main()
  233. {
  234.     char opc = 'd';
  235.     do{
  236.         system("cls");
  237.         printf("A - Control de Vectores\n");
  238.             printf("\t1.- Captura de Datos\n");
  239.             printf("\t2.- Consulta de Datos\n");
  240.             printf("\t3.- Modificacion de Datos\n");
  241.             printf("\t4.- Impresion de Datos\n");
  242.         printf("B - Contol de Matrices\n");
  243.             printf("\t1.- Captura de Datos\n");
  244.             printf("\t2.- Suma de Matrices\n");
  245.             printf("\t3.- Multiplicacion de Matrices\n");
  246.             printf("\t4.- Impresion de Matrices\n");
  247.         printf("C - Fin del Programa\n");
  248.         printf("Selecciona una Opcion: ");
  249.         scanf("%c", &opc);
  250.         switch(tolower(opc))
  251.         {
  252.                    case 'a':
  253.                         menua();
  254.                         break;
  255.                    case 'b':
  256.                         menub();
  257.                         break;
  258.                    case 'c':
  259.                         break;
  260.                    default:
  261.                            printf("Opcion Invalida\n");
  262.                            break;
  263.         }
  264.  
  265.     }while(tolower(opc) != 'c');
  266.  
  267.     return 0;
  268. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement