Skip to content

Instantly share code, notes, and snippets.

View astamatto's full-sized avatar

Alessandro Stamatto astamatto

View GitHub Profile
auto it = find_if( vetor.begin(), vetor.end(),
[](auto& elemento){ return elemento.first == chaveBuscada;} );
import fileinput
from decimal import *
def resolver ():
i = 1
for line in fileinput.input():
a, b = map(Decimal, line.split())
print("Projeto {}:".format(i))
print("Percentual dos juros da aplicacao: {0:.2f} %%".format((b/a - 1) * 100))
i = i + 1
#include <stdio.h>
int main () {
double a, b;
int i = 1;
while (scanf("%lf %lf", &a, &b) == 2)
printf ("Projeto %d:\n"
"Percentual dos juros da aplicacao: %.2lf %% \n",
import sys
def resolver():
entrada = sys.stdin.read()
saida = list(entrada)
x = 0
for i, c in enumerate(entrada):
if c == '\n':
x = 0
elif c != ' ':
import fileinput
def resolver():
for line in fileinput.input():
x = 0
for c in line:
print(c.upper() if x % 2 == 0 else c.lower(), end='')
if c != ' ':
x += 1
#include <iostream>
#include <cctype>
using namespace std;
int main () {
char a;
int x = 0;
cin >> noskipws;
let h: &Vec<Json> = try!(h.as_array().ok_or("Unable to parse halls".to_string()));
if h.len() != 2 { return Err("Invalid number of rooms per hall".to_string()); }
let left = h[0].as_u64().ok_or("Unable to parse Hall left".to_string());
let right = h[0].as_u64().ok_or("Unable to parse Hall left".to_string());
let mut hall = Hall::new_left_right(&self.rooms[left as usize], &self.rooms[right as usize]);
pub fn other(&self, room: &Room) -> Rc<RefCell<Room>> {
match self.left.borrow().name { //name is a String in the Room Struct
ref name if name == room.name => self.right.clone(),
_ => self.left.clone()
}
}
/* Gives:
the trait bound `&std::string::String: std::cmp::PartialEq<std::string::String>` is not satisfied [E0277]
src\game\hall.rs:20 ref name if name == room.name => self.right.clone(),
use std::cmp::Ordering;
#[derive(Debug)]
pub struct Tree<T> (Option<Box<Node<T>>>);
#[derive(Debug)]
pub struct Node<T> {
elem: T,
left: Tree<T>,
right: Tree<T>,
use std::cmp::Ordering;
#[derive(Debug)]
pub struct Tree<T> (Option<Box<Node<T>>>);
#[derive(Debug)]
pub struct Node<T> {
elem: T,
left: Tree<T>,
right: Tree<T>,