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
def pd(processo,mudanca): | |
linhas = len(mudanca) | |
colunas = len(mudanca[0]) | |
nProcessos = len(processo[0]) | |
# Cria a matriz de custos | |
custo = [[None for i in range(colunas)] for x in range(linhas)] | |
# Cria a matriz de caminhos | |
caminho = [[None for i in range(nProcessos)] for x in range(linhas)] |
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
def guloso(produto,preco,peso,mochila_capacidade): | |
naMochila = [] | |
lucro = 0 | |
while True: | |
maiorPreco = 0 | |
index = None | |
for i in range(len(produto)): | |
if (preco[i] > maiorPreco) & (produto[i] not in naMochila) & (mochila_capacidade >= peso[i]): | |
maiorPreco = preco[i] |
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
def guloso(mat, start): | |
notInGraph = list(range(len(mat))) | |
notInGraph.remove(start) | |
pos = start | |
comprimento = len(mat) | |
distanciaTotal = 0 | |
while(notInGraph != []): | |
dist = float('inf') |
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
# -*- coding: utf-8 -*- | |
#len(A) -> Linhas | |
#len(A[N]) -> Colunas | |
def MatrixChainOrder(p): | |
#m => Custos | |
#s => Indice dos Custos | |
#p => Comprimentos |
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
def mochila(n, capacidade, peso, valor): | |
pd = [[0 for i in range(capacidade+1)] for x in range(n+1)] | |
for i in range(1,n+1): | |
for j in range(0,capacidade+1): | |
if peso[i-1] > j: | |
pd[i][j] = pd[i-1][j] | |
else: | |
pd[i][j] = max(pd[i-1][j], (pd[i-1][j-peso[i-1]] + valor[i-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
#include <stdio.h> | |
#define MAX(x,y) x>y?x:y | |
int pd[100][100]; | |
int mochila(int n, int cap, int peso[], int valor[]) | |
{ | |
int i; | |
int j; |
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
def BFS(G,s): | |
Q = [] | |
state = [None for i in range(len(G))] | |
pi = [None for i in range(len(G))] | |
for u in range(len(G)): | |
state[u]='N' | |
pi[u] = None | |
state[s] = 'D' |
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<stdio.h> | |
#include<stdlib.h> | |
int main(void) | |
{ | |
int aux = 0, soma = 0; | |
int i; | |
int vet[] = {-2,-3,4,-1,-2,1,5,-3}; | |
int n = sizeof(vet)/sizeof(int); |
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 "agenda.h" | |
//=== MENU ===// | |
int8_t menu(void) | |
{ | |
/************************* | |
* Munu geral do sistema * | |
*************************/ | |
clrscr(); |
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 "md5.h" | |
//=== MD5 ===// | |
char* md5Sum(char* initial_msg) | |
{ | |
/******************************************************************************************** | |
* A função calcula o MD5 da "string" passada como parâmetro e retorna-o como uma "string". * | |
********************************************************************************************/ | |
OlderNewer