diff --git a/exercicios/01/README.org b/exercicios/01/README.org index 70aac9a..4e155be 100644 --- a/exercicios/01/README.org +++ b/exercicios/01/README.org @@ -6,7 +6,7 @@ * Exercícios da aula 1: História -- [[../aulas/01-historia/README.org][Anotações da aula]] +- [[../../aulas/01-historia/README.org][Anotações da aula]] - [[https://youtu.be/wqJQL5W9FIw][Vídeo]] ** 1. Pesquise e explique diff --git a/exercicios/02/README.org b/exercicios/02/README.org index 3ed6ada..7f77984 100644 --- a/exercicios/02/README.org +++ b/exercicios/02/README.org @@ -6,7 +6,7 @@ * Exercícios da aula 2: Dados e instruções -- [[../aulas/02-dados-e-instrucoes/README.org][Anotações da aula]] +- [[../../aulas/02-dados-e-instrucoes/README.org][Anotações da aula]] - [[https://youtu.be/2KsvRJjshQ0][Vídeo]] diff --git a/exercicios/03/README.org b/exercicios/03/README.org index fc4b427..aa6a157 100644 --- a/exercicios/03/README.org +++ b/exercicios/03/README.org @@ -6,7 +6,7 @@ * Exercícios da aula 3: Tipos de dados -- [[../aulas/03-tipos-de-dados/README.org][Anotações da aula]] +- [[../../aulas/03-tipos-de-dados/README.org][Anotações da aula]] - [[https://youtu.be/iMiRzZCU7hE][Vídeo]] diff --git a/exercicios/04/README.org b/exercicios/04/README.org index 4e14fb7..d5cb0d8 100644 --- a/exercicios/04/README.org +++ b/exercicios/04/README.org @@ -6,7 +6,7 @@ * Exercícios da aula 4: Variáveis e ponteiros -- [[../aulas/04-variaveis/README.org][Anotações da aula]] +- [[../../aulas/04-variaveis/README.org][Anotações da aula]] - [[https://youtu.be/i7RKtMgSSrM][Vídeo]] diff --git a/exercicios/05/README.org b/exercicios/05/README.org index a6952a2..7f18dd4 100644 --- a/exercicios/05/README.org +++ b/exercicios/05/README.org @@ -4,9 +4,9 @@ #+startup: show2levels #+options: toc:3 -* Exercícios da aula 4: Variáveis e ponteiros +* Exercícios da aula 5: Variáveis e ponteiros -- [[../aulas/05-controle/README.org][Anotações da aula]] +- [[../../aulas/05-controle/README.org][Anotações da aula]] - [[https://youtu.be/9dvDL7FbYKY][Vídeo]] diff --git a/exercicios/06/README.org b/exercicios/06/README.org new file mode 100644 index 0000000..d5a9d0e --- /dev/null +++ b/exercicios/06/README.org @@ -0,0 +1,116 @@ +#+title: Curso Básico da Linguagem C +#+subtitle: Exercícios +#+author: Blau Araujo +#+startup: show2levels +#+options: toc:3 + +* Exercícios da aula 6: Vetores + +- [[../../aulas/06-vetores/README.org][Anotações da aula]] +- [[https://youtu.be/W5TGNQYFs4E][Vídeo]] + +** 1. Desafio: Função =print_array_shift= + +Dado o programa abaixo: + +#+begin_src c +#include + +int main(void) { + int vetor[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int desloca = ???; // <--- inicializar com o valor do deslocamento! + + print_array_shift(/* ??? */); + + return 0; +} +#+end_src + +Escreva a função =print_array_shift= de acordo com essa descrição: + +#+begin_example +PROTÓTIPO: + void print_array_shift(int *arr, int size, int shift); + +DESCRIÇÃO: + Desloca para a esquerda os elementos do vetor 'arr', de tamanho 'size', + em 'shift' posições e imprime os valores na sequência resultante. +#+end_example + +No teste, programa deverá imprimir no terminal: + +#+begin_example +:~$ ./a.out +6 7 8 9 10 1 2 3 4 5 +#+end_example + +** 2. Desafio: Função =array_shift= + +Dado o programa abaixo: + +#+begin_src c +#include + +int main(void) { + int vetor[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int desloca = ???; // <--- inicializar com o valor do deslocamento! + + array_shift(/* ??? */); + + /* Rotina de impressão do resultado do deslocamento */ + + return 0; +} +#+end_src + +Crie a função =array_shift= de acordo com a descrição abaixo: + +#+begin_example +PROTÓTIPO: + void array_shift(int *arr, int size, int shift); + +DESCRIÇÃO: + Desloca para a esquerda os elementos do vetor 'arr', de tamanho 'size', + em 'shift' posições. +#+end_example + +A saída do teste deve ser a mesma do desafio anterior. + +** 3. Desafio: Função =array_reverse= + +Dado o programa abaixo: + +#+begin_src c +#include + +int main(void) { + int vetor[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + + /* Rotina da impressão do vetor original */ + + array_reverse(/* ??? */); + + /* Rotina de impressão do vetor invertido */ + + return 0; +} +#+end_src + +Escreva a função =array_reverse= de acordo com a descrição abaixo: + +#+begin_example +PROTÓTIPO: + void array_reverse(int *arr, int size); + +DESCRIÇÃO: + Inverte a ordem dos elementos do vetor 'arr'. +#+end_example + +O teste deverá imprimir... + +#+begin_example +:~$ ./a.out +1 2 3 4 5 6 7 8 9 10 +10 9 8 7 6 5 4 3 2 1 +#+end_example +