AULA 22
Autor: Daniel Santos | Publicado: 2011-08-17T20:13:00-07:00

1 - Faça um algoritmo que preencha uma matriz M (2x2), calcule e mostre a matriz R, resultante da multiplicação dos elementos de M pelo seu maior elemento.
&nbsp;algoritmo "multi_maior_1"
var
&nbsp;&nbsp; m:vetor [1..2,1..2] de real
&nbsp;&nbsp; r:vetor [1..2,1..2] de real
&nbsp;&nbsp; maior,lim,col:real
&nbsp;&nbsp; n,i:inteiro
inicio
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA n de 1 ate 2 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA i de 1 ate 2 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("Digite um número para linha ",n," e para coluna ",i,":")
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leia(m[n,i])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maior&lt;- m[1,1]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pos&lt;- 1,1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA n de 1 ate 2 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA i de 1 ate 2 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SE (maior &lt; m[n,i]) ENTAO
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maior&lt;- m[n,i]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lim&lt;- n
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; col&lt;- i
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMSE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("O número maior da matriz foi",maior)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA n de 1 ate 2 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA i de 1 ate 2 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r[n,i]&lt;- m[n,i] * maior
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("O resultado da multiplicação entre ",m[n,i]," e ",maior," foi ",r[n,i])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
fimalgoritmo

&nbsp;2 - Faça um programa que preencha:
Um vetor com oito posições, contendo nomes de lojas; 
Outro vetor com quatro posições, contendo nomes de produtos; 
Uma matriz com os preços de todos os produtos em cada loja. 

O programa deverá mostrar todas as relações (nome do produto – nome da loja) em que o preço não ultrapasse R$ 120,00.

algoritmo "aula22_ex2"
var
&nbsp; loja: vetor [1..8] de caractere
&nbsp; prod: vetor [1..4] de caractere
&nbsp; preco: vetor [1..8,1..4] de real
&nbsp; i, j : inteiro
inicio
&nbsp; para i &lt;- 1 ate 8 faca
&nbsp;&nbsp;&nbsp; escreval("Digite o nome da loja ",i)
&nbsp;&nbsp;&nbsp; leia(loja[i])
&nbsp; fimpara
&nbsp; para i &lt;- 1 ate 4 faca
&nbsp;&nbsp;&nbsp; escreval("Digite o nome do produto ",i)
&nbsp;&nbsp;&nbsp; leia(prod[i])
&nbsp; fimpara
&nbsp; para i &lt;- 1 ate 8 faca
&nbsp;&nbsp;&nbsp; para j &lt;- 1 ate 4 faca
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("Digite o preco do(a) ",prod[j]," na loja ",loja[i])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leia(preco[i,j])
&nbsp;&nbsp;&nbsp; fimpara
&nbsp; fimpara
&nbsp; para i &lt;- 1 ate 8 faca
&nbsp;&nbsp;&nbsp; para j &lt;- 1 ate 4 faca
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; se (preco[i,j] &lt;= 120) entao
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval(prod[j]," custa R$",preco[i,j]," na loja ",loja[i])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fimse
&nbsp;&nbsp;&nbsp; fimpara
&nbsp; fimpara
fimalgoritmo

&nbsp;3 - Na teoria dos sistemas, define-se o elemento MINMAX de uma matriz como o maior elemento da linha em que se econtra o menor elemento da matriz. Elabore um programa que carregue uma matriz 4x7 com números reais, calcule e mostre seu MINMAX e sua posição (linha e coluna).
&nbsp;algoritmo "minmax3"
var
&nbsp;&nbsp; mat:vetor[1..4,1..7] de real
&nbsp;&nbsp; menor,maior,coluna,colunamaior,linha: real
&nbsp;&nbsp; n,i: inteiro
inicio
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA n de 1 ate 4 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA i de 1 ate 7 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("Digite o número pertencente a coluna ",i," e a linha ",n,":")
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leia(mat[n,i])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; menor&lt;- mat[1,1]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; linha&lt;- 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; coluna&lt;- 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA n de 1 ate 4 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA i de 1 ate 7 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SE menor &lt; mat[n,i] ENTAO
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; colunamaior&lt;- i
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMSE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("O menor número é ",menor," esta na linha ",linha,",e na coluna ",coluna," e o maior desta linha é ",maior," esta na coluna ",colunamaior)
fimalgoritmo


&nbsp;algoritmos e um tanto quanto viciante, as vezes chegamos a um ponto onde parecemos viciados em algo, ate então to a cada dia mais fisurado em desenvolver estas questões, tenho sim minhas dificuldades mas to tentando, to me esforçando e quero sim nesta carreira muito sucesso e sei que pra isso preciso de determinação.&nbsp; ...

espero sim e com minha determinação alcançar meus objetivos