View Q01.rb
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 lerInt(n) | |
n.times.map do | |
gets.to_i | |
end | |
end | |
vetor1 = lerInt(3) | |
vetor2 = lerInt(4) | |
vetor3 = vetor1 + vetor2 | |
print vetor3 |
View Dado.rb
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
class Dado | |
def rolar | |
return 1 + rand(6) | |
end | |
end |
View Q01.rb
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
# Escreva uma classe, chamada Ponto, que representa um ponto no | |
# plano cartesiano. A figura abaixo mostra quais atributos e métodos | |
# da classe. | |
class Ponto | |
attr_reader :x, :y | |
def initialize(x,y) | |
@x = x | |
@y = y |
View bomba.rb
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
class Bomba | |
attr_reader :x, :y, :ativa | |
def initialize(janela) | |
@janela = janela | |
@icon = Gosu::Image.new(@janela, 'bomba.png', true) | |
@y = -rand(200) | |
@x = rand(@janela.width-60) | |
@ativa = true | |
end | |
def update(laser) |
View Map.scala
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
package main.scala | |
import math.{ abs, min } | |
import Int.MaxValue | |
case class Map(val airports: Seq[(Int, Int)] = Seq(), val clouds: Seq[(Int, Int)] = Seq()) { | |
def addAirports(coordinates: Seq[(Int, Int)]) = Map(airports ++ coordinates, clouds) | |
def airportAt(coordinate: (Int, Int)) = airports.exists(_ == coordinate) |
View Map.scala
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
package main.scala | |
import math.{ abs, min } | |
import Int.MaxValue | |
case class Map(val airports: Seq[(Int, Int)] = Seq(), val clouds: Seq[(Int, Int)] = Seq()) { | |
def addAirports(coordinates: Seq[(Int, Int)]) = Map(airports ++ coordinates, clouds) | |
def airportAt(coordinate: (Int, Int)) = airports.exists(_ == coordinate) |
View Fat.poti
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
f(x: Inteiro): Inteiro = escolha x | |
caso 0 => 1 | |
caso n => n * f(n - 1) | |
fim | |
solução = | |
para x de 0 até 10 se f(x + 3) + f(x + 2) == 8 * f(x + 1) gere x fim | |
escreva solução |
View Exercicios01.rb
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
# Questao 1 | |
"Programacao de Computadores".size | |
# ou | |
"Programacao de Computadores".length | |
# Questao 2 | |
media = (8.12 + 7.45) / 2.0 | |
"A sua media foi de "+ media.to_s + " este ano!" | |
# ou como será visto mais adiante ... |
View ServidorHttp.java
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 java.io.*; | |
import java.net.*; | |
public class ServidorHttp { | |
public static void main(String args[]) { | |
ServerSocket s = null; | |
try { | |
s = new ServerSocket(7896); | |
// right now the stream is open. | |
while (true) { |
View programa1.rb
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
#encoding: UTF-8 | |
puts "Meu primeiro programa!" |