Advertisement
fabi2295

CPF portugol

May 28th, 2015
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. algoritmo "CPF"
  2.  
  3. var
  4. numero :vetor[1..11] de inteiro
  5. soma,i : inteiro
  6. CPF : caractere
  7. resto1, resto2 : real
  8. inicio
  9. escreval("Digite CPF(só os números)")
  10. leia(CPF)
  11.  
  12. para i de 1 ate 11 faca
  13. numero[i] <- Caracpnum(Copia(CPF,i, 1))
  14. fimpara
  15.  
  16. para i de 1 ate 9 faca
  17. soma <- soma + (numero[i] * (11 - i))
  18. fimpara
  19.  
  20. resto1 <- (soma % 11)
  21.  
  22. se (resto1 > 1) entao
  23. resto1 <- 11 - (resto1)
  24. senao
  25. resto1 <- 0
  26. fimse
  27.  
  28. soma <- 0
  29.  
  30. para i de 1 ate 10 faca
  31. soma <- soma + (numero[i] * (12 - i))
  32. fimpara
  33.  
  34. resto2 <- (soma % 11)
  35.  
  36. se (resto2 > 1 ) entao
  37. resto2 <- 11 - (resto2)
  38. senao
  39. resto2 <- 0
  40. fimse
  41.  
  42. se cpf = "00000000000" entao
  43. escreval("CPF INVALIDO")
  44. senao
  45. se ((resto1 = numero[10]) e (resto2 = numero[11])) entao
  46. escreval("CPF valido : ",CPF)
  47. senao
  48. escreval("CPF invalido : ",CPF)
  49. fimse
  50. fimse
  51. fimalgoritmo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement