Advertisement
LuandaBernardo

Lista 2 - Q12

Nov 22nd, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. /*12) Faça um programa que:
  2. a) Leia uma matriz 3x3 de números inteiros.
  3. b) Imprima-a em formato matricial.
  4. c) Leia um número inteiro k.
  5. d) Atualize a matriz com seu valor multiplicado por k, e imprima-a no formato matricial. */
  6.  
  7.  
  8. #include<stdio.h>
  9. #include<conio.h>
  10.  
  11.  
  12. main ()
  13. {
  14.     int matriz[3][3], i, j, k;
  15.    
  16.     for (i=0; i<3; i++)
  17.     {
  18.         for (j=0; j<3; j++)
  19.         {
  20.             printf ("\n[%d][%d] = ", i,j);
  21.             scanf ("%d", &matriz[i][j]);
  22.         }
  23.     }
  24.    
  25.     for (i=0; i<3; i++)
  26.     {
  27.         for (j=0; j<3; j++)
  28.         {
  29.             printf ("\t  %d",  matriz[i][j]);
  30.        
  31.         }
  32.         printf ("\n ");
  33.     }
  34.    
  35.     printf("\n Digite um numero:  ");
  36.     scanf ("%d", &k);
  37.    
  38.     for (i=0; i<3; i++)
  39.     {
  40.         for (j=0; j<3; j++)
  41.         {
  42.         matriz[i][j] = k*matriz[i][j];
  43.         }
  44.     }
  45.         for (i=0; i<3; i++)
  46.     {
  47.         for (j=0; j<3; j++)
  48.         {
  49.             printf ("\t  %d",  matriz[i][j]);
  50.        
  51.         }
  52.         printf ("\n ");
  53.     }
  54.    
  55.     getch();
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement