N

@NichollasM

L6 - Exercício 5

C
1 year ago
#include <stdio.h> int gcd(int a, int b){ if(b == 0) return a; else return gcd(b, a%b); } int main(void){

L6 - Exercício 4

C
1 year ago
#include <stdio.h> #include <stdlib.h> #include <string.h> void inverte(char* word, int ini, int fim){ if(ini > fim) return; // necessário trocar antes de usar a função recursiva char temp = word[ini];

L6 - Exercício 3

C
1 year ago
#include <stdio.h> #include <stdlib.h> int soma(int *v, int n){ if(n == 0){ return v[0]; } else{ return v[n - 1] + soma(v, n + 1); }

L6 - Exercício 2

C
1 year ago
#include <stdio.h> double power(double a, int b){ if(b == 0) return 1; else return a * power(a, b - 1); } int main(void){

L6 - Exercício 1

C
1 year ago
#include <stdio.h> void count_down(int n){ if(n == 1){ printf("%d\n", n); } else{ printf("%d\n", n); count_down(n-1); } }

L5 - Exercício 14

C
1 year ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

L5 - Exercício 13

C
1 year ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

L5 - Exercício 12

C
1 year ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

L5 - Exercício 11

C
1 year ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

L5 - Exercício 10

C
1 year ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

L5 - Exercício 9

C
1 year ago
#include <stdio.h> #include <stdlib.h> #define MAX 100 int **matriz_le(int n, int m){ // obs: na alocação de matrizes de ponteiros, é necessário alocar primeiro as linhas e dps a coluna. int **M = malloc(n * sizeof(int)); // Aqui aloquei o vetor

L5 - Exercício 8

C
1 year ago
#include <stdio.h> #include <stdlib.h> #include <string.h> char* revert(char* s){ int tam = strlen(s); // tamanho da string char* revertido = malloc(tam * sizeof(char) + 1); // alocação dinâmica do vetor de String revertido if(revertido == NUL

L5 - Exercício 7

C
1 year ago
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }

L5 - Exercício 6

C
1 year ago
#include <stdio.h> #include <stdlib.h> #include <string.h> char* str_cat(char *strA, char *strB){ int tamanho = strlen(strA) + strlen(strB) + 1; // define o tamanho das strings (+1 por conta do '\0') char* concatena = malloc(tamanho * sizeof(ch

L5 - Exercício 5

C
1 year ago
#include <stdio.h> #define MAX 100 void le_vetor(int v[], int n){ for(int i = 0; i < n; i++){ scanf("%d", &v[i]); } } void swap(int **vetor_A, int **vetor_B){

L5 - Exercício 4

C
1 year ago
#include <stdio.h> void inc(int* x){ *x += 1; } int main(void){ int x; scanf("%d", &x);

L5 - Exercício 3

C
1 year ago
#include <stdio.h> void swap(int *a, int *b){ int temp = *a; *a = *b; *b = temp; } int main(void){ int a, b;

L5 - Exercício 2

C
1 year ago
#include <stdio.h> #include <stdlib.h> int main() { int n, i; scanf("%d", &n); char* v = malloc(n * sizeof(char)); for(i = 0; i < n; i++){

L5 - Exercício 1

C
1 year ago
#include <stdio.h> #include <stdlib.h> int main() { int n; scanf("%d", &n); double *v; v = malloc(n * sizeof(double));

Aula 5 - Ex 1

C
1 year ago
#include <stdio.h> #include <stdlib.h> double * aloca(int n){ double *v; v = malloc(n * sizeof(double)); // alocação da região de memória if (v == NULL){ // verifica se a memória acabou printf("Memória insuficiente\n");