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 public serie1a100 | |
.super java/lang/Object | |
; imprime os numeros de 1 a 100 | |
.method public static main([Ljava/lang/String;)V | |
.limit stack 10 | |
.limit locals 2 | |
getstatic java/lang/System/out Ljava/io/PrintStream; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Exemplo JavaScript</title> | |
</head> | |
<body> | |
<div id="cabecalho"><h1>www.GeeksBR.com</h1></div> | |
<div id="main"> | |
<div class="row"> |
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
window.addEventListener("load", function() { | |
// selecionando o botão | |
var linguagem = document.getElementById("linguagem"); | |
var nome = document.getElementById("nome"); | |
var botao_enviar = document.getElementById("botao_enviar"); | |
var area_texto = document.getElementById("area_texto"); | |
var abrir_geeksbr = document.getElementById("abrir_geeksbr"); | |
var alerta_nome = document.getElementById("alerta_nome"); | |
// função associada ao evento de clique do botão "Enviar resposta" |
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
-- maior valor de uma lista | |
maior [a] = a | |
maior (a:x) = if (a > (maior x)) then a else (maior x) | |
-- segunda forma de fazer | |
maior2 [a] = a | |
maior2 (a:b:x) | a > b = maior2(a:x) | |
| otherwise = maior2(b:x) | |
-- terceira forma de fazer (mais eficiente) |
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
# descartando o primeiro e o último elemento da lista | |
lista = [1,2,3,4,5,6] | |
primeiro, *resto, segundo = lista | |
print(resto) # a variável resto é uma lista | |
# recusão para somar itens de uma lista usando desempacotamento com asterisco | |
def soma(lista): | |
cabeca, *cauda = lista | |
return cabeca + soma(cauda) if cauda else cabeca | |
print(soma([1,2,3,4,5])) |
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
// www.geeksbr.com | |
var valor1 = 3 + "4"; | |
var valor2 = "4" * 2; | |
var valor3 = 3 + "4" - 2; | |
var valor4 = ("4" + "0") / 2 + "10" |
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
// www.geeksbr.com | |
// Operador de identidade (igualdade estrita) | |
/* | |
Esse operador testa tanto o valor | |
quanto o tipo | |
Símbolo: === (três sinais de igual) | |
*/ |
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 | |
# problema: http://dojopuzzles.com/problemas/exibe/caixa-eletronico/ | |
def result(saque): | |
d = {'100':0, '50':0, '20':0, '10':0} | |
d['100'] = saque//100 | |
saque = saque - d['100']*100 | |
d['50'] = saque//50 | |
saque = saque - d['50']*50 | |
d['20'] = saque//20 |
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
#include <stdio.h> | |
#include <string.h> | |
void lerNome(char *nome) | |
{ | |
printf("Digite um nome: "); | |
scanf("%s", nome); | |
} | |
void imprimeNomeInvertido(char *nome) |
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
// exemplo do uso de parâmetros opcionais em C++ | |
// www.GeeksBR.com | |
#include <iostream> | |
using namespace std; | |
int inc_num(int n, int add = 0) | |
{ |
OlderNewer