mirror of
https://gitlab.com/blau_araujo/cblc.git
synced 2025-05-11 02:56:35 -03:00
Atualização de todos os exercícios
This commit is contained in:
parent
02c7f15a66
commit
643c375aaf
6 changed files with 122 additions and 6 deletions
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
* Exercícios da aula 1: História
|
* 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]]
|
- [[https://youtu.be/wqJQL5W9FIw][Vídeo]]
|
||||||
|
|
||||||
** 1. Pesquise e explique
|
** 1. Pesquise e explique
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
* Exercícios da aula 2: Dados e instruções
|
* 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]]
|
- [[https://youtu.be/2KsvRJjshQ0][Vídeo]]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
* Exercícios da aula 3: Tipos de dados
|
* 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]]
|
- [[https://youtu.be/iMiRzZCU7hE][Vídeo]]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
* Exercícios da aula 4: Variáveis e ponteiros
|
* 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]]
|
- [[https://youtu.be/i7RKtMgSSrM][Vídeo]]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
#+startup: show2levels
|
#+startup: show2levels
|
||||||
#+options: toc:3
|
#+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]]
|
- [[https://youtu.be/9dvDL7FbYKY][Vídeo]]
|
||||||
|
|
||||||
|
|
||||||
|
|
116
exercicios/06/README.org
Normal file
116
exercicios/06/README.org
Normal file
|
@ -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 <stdio.h>
|
||||||
|
|
||||||
|
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 <stdio.h>
|
||||||
|
|
||||||
|
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 <stdio.h>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
Loading…
Add table
Reference in a new issue