This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar Enquanto; | |
programa : seqComando; // sequência de comandos | |
seqComando: comando (';' comando)* ; | |
comando: ID ':=' expressao # atribuicao | |
| 'skip' # skip | |
| 'se' bool 'entao' comando 'senao' comando # se | |
| 'enquanto' bool 'faca' comando # enquanto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program XX | |
use crt; | |
print("wqwwq") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Programa CPF | |
verifica_digito(cpf: Lista[Inteiro]) | |
var soma = 0 | |
tam = cpf.tamanho | |
para i de 2 até tam + 1 faça | |
soma := soma + i * cpf[tam + 2 - i] | |
fim | |
resto = soma mod 11 | |
se resto < 2 então 0 senão 11 - resto fim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$n = M1+M2 | |
def f(a) | |
n = $n + (a * 2) | |
$n = $n+1 | |
return n | |
end | |
def g(a) | |
$n = $n + a + 1 | |
x = $n*2 | |
return x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fc(x,y) | |
s=0 | |
a = x.split(“”) | |
for i in a do | |
if (y==a[i]) then | |
s = s + 1 | |
end | |
end | |
return s | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Importar os métodos de StdIn (readInt, readLine, ...) | |
import scala.io.StdIn._ | |
// Variáveis (o tipo é inferido a partir do valor atribuído) | |
val x = 10 // Constante (é a forma preferível) | |
val x: Int = 10 // | |
var y = 20 | |
y = y + 10 | |
// Entrada de dados |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Funcionário usando classe | |
*/ | |
trait Pessoa { | |
def nome: String | |
} | |
class Funcionario(val nome: String, _salario: Double) extends Pessoa { | |
def salario = _salario |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.mutable.Buffer | |
class Contato( | |
var nome: String, | |
var email: String, | |
var telefone: Map[String, String], | |
var cidade: String = "") { | |
} | |
class Agenda() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Crie um programa para construir uma página HTML usando a função: | |
def pagina(font: String, cor: String)(titulo: String, | |
pessoas: List[Pessoa], mensagem: String): String | |
Uma pessoa pode ser um Aluno (nome, matricula, curso, periodo) | |
ou | |
Professor (nome, matricula, disciplina, diretoria). | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.dropbox.com/s/nny7objxs401rnn/potigol097.zip?dl=0 |