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 / lscanf.c
Last active November 3, 2022 13:35
Maneira segura de pegar o input do usuário
/********************
* Developed by Luiz Felipe.
*
* GitHub: https://github.com/Silva97
* Facebook: https://www.facebook.com/B4.0E.B0.48.CD.10.B0.69.CD.10.C3
********************/
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
/********************
* Exemplo de replace em C.
* Por Luiz Felipe.
* https://github.com/Silva97
********************/
#include <stdio.h>
#include <string.h>
int replace(char *text, char *word, char *new);
/********************
* 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>
enum {
RECT_T = '-', // Aresta do topo
RECT_TR = '+', // Vértice do canto superior direito
RECT_R = '|', // Aresta da direita
RECT_BR = '+', // Vértice do canto inferior direito
RECT_B = '-', // Aresta da parte inferior
RECT_BL = '+', // Vértice do canto inferior esquerdo
RECT_L = '|', // Aresta da esquerda
#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;
};
/*********************
* Resolução do problema: https://leetcode.com/problems/reverse-integer/
*********************/
int aux_rev(int x, long long int rev)
{
if(rev > INT_MAX || rev < INT_MIN) return 0;
if(!x) return rev;
return aux_rev(x/10, rev*10 + x%10);
#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";