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
| // https://medium.com/@FreeDev/modularizando-c%C3%B3digo-em-c-784dc52d1c34 | |
| #include <stdio.h> | |
| #include "module.h" | |
| int main(void) | |
| { | |
| printf("Valor: %d\n", sum(3, 7)); | |
| return 0; |
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 getint(int *number); | |
| int main() | |
| { | |
| int n; | |
| fputs("Digite um inteiro cara: ", stdout); |
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 <inttypes.h> | |
| uint32_t fib(int n) | |
| { | |
| register uint32_t r = 0; | |
| __asm__( | |
| "mov $1, %%ebx\n\t" | |
| ".lp%=:\n\t" |
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> | |
| int main(void) | |
| { | |
| fputs("Dia da semana(1~7): ", stdout); | |
| printf("Nome do dia: %s\n", | |
| ((char [][16]){ | |
| "Domingo", | |
| "Segunda", |
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 <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"; |
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
| /********************* | |
| * 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); |
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 <string.h> | |
| #include <stdlib.h> | |
| struct test { | |
| char str[10]; | |
| int n; | |
| }; |
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 tostr(...) #__VA_ARGS__ | |
| #define type(x) _Generic(x, \ | |
| int: "int", \ | |
| unsigned int: "unsigned int", \ | |
| short int: "short int", \ | |
| int *: "int *", \ | |
| char: "char", \ | |
| char *: "char *", \ |
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> | |
| 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; |
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> | |
| 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 |