Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*12) Faça um programa que:
- a) Leia uma matriz 3x3 de números inteiros.
- b) Imprima-a em formato matricial.
- c) Leia um número inteiro k.
- d) Atualize a matriz com seu valor multiplicado por k, e imprima-a no formato matricial. */
- #include<stdio.h>
- #include<conio.h>
- main ()
- {
- int matriz[3][3], i, j, k;
- for (i=0; i<3; i++)
- {
- for (j=0; j<3; j++)
- {
- printf ("\n[%d][%d] = ", i,j);
- scanf ("%d", &matriz[i][j]);
- }
- }
- for (i=0; i<3; i++)
- {
- for (j=0; j<3; j++)
- {
- printf ("\t %d", matriz[i][j]);
- }
- printf ("\n ");
- }
- printf("\n Digite um numero: ");
- scanf ("%d", &k);
- for (i=0; i<3; i++)
- {
- for (j=0; j<3; j++)
- {
- matriz[i][j] = k*matriz[i][j];
- }
- }
- for (i=0; i<3; i++)
- {
- for (j=0; j<3; j++)
- {
- printf ("\t %d", matriz[i][j]);
- }
- printf ("\n ");
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement