Skip to content

Instantly share code, notes, and snippets.

View Silva97's full-sized avatar
🤔
Thinking, of course.

Luiz Felipe Silva Silva97

🤔
Thinking, of course.
View GitHub Profile
@Silva97
Silva97 / math.c
Last active February 22, 2018 19:39
/********************
* Exemplo de cálculo matemático de divisão e multiplicação
* feito com soma e subtração.
*
* Por Luiz Felipe - https://github.com/Silva97
********************/
#include <stdio.h>
#define PRECISION 1000000
/********************
* Desenvolvido por Luiz Felipe
* https://github.com/Silva97
*
* Algoritmo feito em resolução de um desafio
* cujo o objetivo era apresentar o menor número
* de persistência indicada pelo usuário.
*
* Desafio no grupo Programação em C:
* - https://www.facebook.com/groups/414761988665865/permalink/1144414109033979/
#include <stdio.h>
#define MAX_STACK 64
typedef struct stack {
int value[MAX_STACK];
int size;
} Stack;
void push(Stack *s, int value);
/********************
* Exemplo maluco por Luiz Felipe.
*
* https://github.com/Silva97
********************/
#include <stdio.h>
#define UCHARPTR (unsigned char *)
function sum(...args){
var result = 0;
if(args.length == 4){
for(let i = 0; i < args.length; i++)
result += args[i];
return result;
} else {
return function(...newArgs){
#include <stdio.h>
int main(){
int x, y;
scanf("%d", &x);
switch(x){
case 1: y = 7; break;
case 2: y = 1; break;
case 3: y = 3; break;
#include <stdio.h>
#define tostr(...) #__VA_ARGS__
#define type(x) _Generic(x, \
int: "int", \
unsigned int: "unsigned int", \
short int: "short int", \
int *: "int *", \
char: "char", \
char *: "char *", \
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct test {
char str[10];
int n;
};
#include <iostream>
int operator +(int x, std::string str){
return x + std::stoi(str, nullptr, 10);
}
int main(void)
{
int x = 5;
std::string str = "13";
/********************
* Resolução para o problema: https://www.urionlinejudge.com.br/judge/pt/problems/view/1026
* Por Luiz Felipe - https://github.com/Silva97
********************/
#include <stdio.h>
#include <stdlib.h>
char* utostr(char *str, unsigned int n);
char output[BUFSIZ];