This file contains hidden or 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 <string.h> | |
| #include <stdio.h> | |
| int login(char *password) { | |
| int secret = 0; | |
| char buffer[16]; | |
| strcpy(buffer, password); | |
| if (secret == 0x231da6e1){ | |
| printf("Welcome! ;)\n"); |
This file contains hidden or 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 <string.h> | |
| #include <stdio.h> | |
| int login(char *password) { | |
| int auth_flag = 0; | |
| char buffer[16]; | |
| strcpy(buffer, password); | |
| if (strcmp(buffer,"zeldani") == 0) | |
| auth_flag = 1; |
This file contains hidden or 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
| # Esse sera nosso primeiro tcl script :) | |
| bind join - * join:voice_n_greet | |
| proc join:voice_n_greet { nick host hand chan } { | |
| if { $nick == "dtty" } { | |
| pushmode $chan +o $nick | |
| puthelp "PRIVMSG $chan :dtty eh o meu nick favorito. <3" | |
| } else { | |
| pushmode $chan +v $nick | |
| puthelp "PRIVMSG $chan :Ahoy pirate $nick!" |
This file contains hidden or 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 base64 | |
| codigo = base64.b64encode('dado a ser codificado') | |
| print codigo | |
| texto = base64.b64decode(codigo) | |
| print texto |
This file contains hidden or 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
| from string import maketrans | |
| intab = "aeiou" | |
| outtab = "4310V" | |
| transtab = maketrans(intab, outtab) | |
| str = raw_input(">> "); | |
| print str.translate(transtab); |
This file contains hidden or 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 01: | |
| import codecs | |
| texto1 = codecs.encode("dado para ser codificado", "rot13") | |
| print texto1 | |
| # Exemplo 02: | |
| texto2 ='dado para ser codificado' | |
| print texto2.encode('rot-13') | |
| # Exemplo 03: |
This file contains hidden or 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 vetor: | |
| def __init__(self, a, b): | |
| self.a = a | |
| self.b = b | |
| def __str__(self): | |
| return 'Vetor (%d, %d)' % (self.a, self.b) | |
| def __add__(self, outro): | |
| return vetor(self.a + outro.a, self.b + outro.b) | |
| v1 = vetor(3, 10) | |
| v2 = vetor(8, -2) |
This file contains hidden or 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 A: | |
| def __init__(self, a, b): | |
| self.a, self.b = a, b | |
| def conta(self, x): | |
| return self.a*x+self.b | |
| class B: | |
| def __init__(self, texto): | |
| self.texto = texto | |
| def escreve(self, valor): | |
| print self.texto,'=', valor |
This file contains hidden or 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 A: | |
| n = 5 | |
| def conta(self, x): return A.n*x | |
| class B(A): | |
| def conta(self, x): return A.conta(self, x)**2 | |
| def outraconta(self, x): return self.conta(x)+1 | |
| a = A() | |
| b = B() | |
| print a.conta(4) | |
| print b.conta(3) |
This file contains hidden or 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 Animal: | |
| def __init__(self, nome): | |
| self.nome = nome | |
| class Gato(Animal): | |
| def fala(self): | |
| return 'Miau!' | |
| class Cachorro(Animal): | |
| def fala(self): | |
| return 'Au! Au!' | |
| animais = [Gato('Kitty'), |
NewerOlder