AULA 20 - 29/06/2011 - Matrizes
Autor: Maike Nunes | Publicado: 2011-06-30T09:48:00-07:00

&nbsp;&nbsp; Na aula de hoje nos foi passado mais uma matéria nova. Começamos a estudar agora também as matrizes, o professor Jossandro passou a teoria em slides que disponibilizarei abaixo e passou também dois execicios para melhor compreensão na prática, disponibilizarei todos resolvidos.



1 - Faça um programa que preencha uma matriz 10 x 3 com as notas de dez alunos em três provas. O programa deverá mostrar um relatório com o número dos alunos (numero da linha) e a prova em que cada aluno obteve menor nota. Ao final do relatório, deverá mostrar quantos alunos tiveram menor nota em cada uma das provas: na prova 1, na prova 2 e na prova 3.

algoritmo "prova1"
var
&nbsp;&nbsp; not: vetor [1..10, 1..3] de real
&nbsp;&nbsp; cont1, cont2, cont3, l, c: inteiro
inicio
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA l de 1 ate 10 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA c de 1 ate 3 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("Digite a nota da prova ",c," do aluno ",l,": ")
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leia(not[l,c])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont1&lt;-0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont2&lt;-0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont3&lt;-0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA l de 1 ate 10 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SE (not[l,1] &lt;= not[l,2]) e (not[l,1] &lt;= not[l,3]) ENTAO
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont1&lt;- cont1 + 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("A menor nota do aluno ",l," é ", not[l,1])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SENAO
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SE (not[l,2] &lt;= not[l,1]) e (not[l,2] &lt;= not[l,3]) ENTAO
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont2&lt;- cont2 + 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("A menor nota do aluno ",l," é ", not[l,2])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SENAO
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SE (not[l,3] &lt;= not[l,2]) e (not[l,3] &lt;= not[l,1]) ENTAO
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont3&lt;- cont3 + 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("A menor nota do aluno ",l," é ", not[l,3])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMSE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMSE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval(cont1," alunos tiveram a menor nota na prova 1")
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval(cont2," alunos tiveram a menor nota na prova 2")
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval(cont3," alunos tiveram a menor nota na prova 3")
fimalgoritmo

Download arquivo alg.

2 - Faça um programa que preencha uma matriz de 5 x 5 com números inteiros, calcule e mostre os números superiores a cinquenta e suas respectivas posições (linha e coluna). O programa deverá mostrar mensagem se não existir nenhum número nessa condição. 

algoritmo "soma2"
var
&nbsp;&nbsp; som: vetor [1..5, 1..5] de inteiro
&nbsp;&nbsp; cont, l, c: inteiro
inicio
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA l de 1 ate 5 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA c de 1 ate 5 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("Digite o número referente a linha ",l," e coluna ",c,":")
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leia(som[l,c])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMPARA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont&lt;- 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA l de 1 ate 5 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PARA c de 1 ate 5 FACA
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SE (som[l,c] &gt; 50) ENTAO
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont&lt;- cont +1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("O número referente a linha ",l," e coluna ",c," é maior do que 50")
&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; SE (cont = 0) ENTAO
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escreval("Nenhum número digitado foi maior do que 50")
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FIMSE
fimalgoritmo

Download arquivo alg.

&nbsp;&nbsp; Hoje no inicio da explicação achei que teria mais dificuldade com o conteudo, mas depois da explicação do professor vi que a materia não era nem um bicho de sete cabeças, com escessão da matriz tridimensional, na pratica foi bem melhor compreendida, ja que tudo na pratica se é mais entendido, a dificuldade fica por conta da tão falada lógica que as vezes acaba nos traindo, mas consegui resolver os exercicios numa boa.