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 div_by_three_or_five(arry) | |
sum = 0 | |
arry.each do |item| | |
if item % 3 == 0 or item % 5 == 0 | |
sum += item | |
end | |
end | |
sum | |
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
class Livro | |
attr_accessor :titulo, :lancamento, :autor | |
def initialize(titulo, lancamento, autor) | |
self.titulo = titulo | |
self.lancamento = lancamento | |
self.autor = autor | |
end | |
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
require 'nokogiri' | |
require 'open-uri' | |
url = 'http://pt.wikipedia.org/wiki/Anexo:Lista_de_munic%C3%ADpios_do_Brasil' | |
doc = Nokogiri::HTML open url | |
xml_file = "cities.xml" | |
File.delete xml_file if File.exists? xml_file |
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
"my first vimscript function | |
function! <sid>BackgroundToggle() | |
if &background == 'dark' | |
set background=light | |
else | |
set background=dark | |
endif | |
endfunction | |
"call function |
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 <iostream> | |
using namespace std; | |
int main (int argc, char * const argv[]) { | |
int sum = 0; | |
for (int x = 0; x <= 100; x++) { | |
sum += 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
#include <iostream> | |
#include <math.h> | |
using namespace std; | |
int main (int argc, char * const argv[]) { | |
int cont; | |
for(cont = 15; cont <= 200; cont++) { | |
cout << "O quadrado de "<< cont <<" = "; |
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 <iostream> | |
using namespace std; | |
int main (int argc, char * const argv[]) { | |
double H = 0; | |
cout << "Digite um valor para obter o calculo de H ..." << endl; | |
int N; | |
scanf("%d", &N); |
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 <iostream> | |
using namespace std; | |
class fibonacci { | |
public: | |
static int calc_fibonacci(int n) { | |
int f, f1, f2; | |
if (n <= 2) { |
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
//O maximo divisor comum de dois inteiros é o maior número que divide ambos | |
//sem deixar o resto. Escreva um programa que lê dois inteiros e calcula o seu | |
//máximo divisor comum. | |
#include <iostream> | |
using namespace std; | |
int MDC(int n1, int n2){ | |
int resto; | |
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
//n7 | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int maxValue(vector<int> &array) { | |
int size = array.size(); | |
int max = array[0]; | |
OlderNewer