Question vector portugol

Two questions about vectors and matrices. 1_give any vector with 100 integers, make a module that tells you whether or not there is repeated numbers on this vector.

Algorithm "repetition in Vector"

Var
// Seção de Declarações das variáveis 
vet : vetor [1..10] de inteiro
i,j, aux: inteiro
rep: inteiro

Inicio
// Seção de Comandos, procedimento, funções, operadores, etc... 
para i de 1 ate 10 faca
leia (vet[i])
fimpara

para i de 1 ate 9 faca
para j de i ate 10 faca
     se vet[j] < vet[i] entao
        aux <- vet[j]
        vet[j] <- vet[i]
        vet[i]<- aux
     fimse
fimpara
fimpara
para i de 1 ate 10 faca
escreva (vet[i])
fimpara
rep<- (vet[1])
 para i de 1 ate 10 faca
      se (vet[i] = rep) entao
         escreva ("O numero", rep," está repetido.")
      fimse
 fimpara

Fimalgoritmo

/ / in this algorithm unfortunately it only points if it has only 1 repeated number.

2_give a vector of 20 real numbers and a 20x20 matrix of real numbers, enter which rows and columns are equal to the vector, whether it is in the given order or in reverse order. Assume that obligatorily there is a row or column equal to the vector in the Matrix.

 2
Author: rray, 2016-04-12

1 answers

If you want to see the amount of repeated numbers, you will need to make a variable cont.

To store the repeated numbers can make an extra vector and stores them there.

This Part:

    se vet[j] < vet[i] entao
    aux <- vet[j]
    vet[j] <- vet[i]
    vet[i]<- aux
    fimse

(do not need to do sorting just see if it repeats)

Creates a variable k.

    k:inteiro
    vet2 : vetor [1..10] de inteiro

    k<-1
    para i de 1 ate 10 faca
    para j de 1 ate 10 faca
    se vet[j] = vet[i] entao
    vet2[k]<-vet[j]
    k=k+1

   fimse
   fimpara
   fimpara
    //depois realiza um laço para escrever o vetor k na qual 
 1
Author: YODA, 2017-10-20 13:17:23