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
auto it = find_if( vetor.begin(), vetor.end(), | |
[](auto& elemento){ return elemento.first == chaveBuscada;} ); |
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 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 |
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> | |
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", |
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 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 != ' ': |
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 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 |
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 <cctype> | |
using namespace std; | |
int main () { | |
char a; | |
int x = 0; | |
cin >> noskipws; |
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
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]); |
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
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(), |
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
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>, |
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
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>, |