mirror of
https://gitlab.com/blau_araujo/cblc.git
synced 2025-05-10 18:46:36 -03:00
Compare commits
3 commits
7560d3a58c
...
02c7f15a66
Author | SHA1 | Date | |
---|---|---|---|
02c7f15a66 | |||
cedfd01328 | |||
9ca337fea2 |
5 changed files with 42 additions and 11 deletions
|
@ -25,3 +25,4 @@ qualquer distribuição.
|
||||||
- 17.03.2025 [[./aulas/03-tipos-de-dados/README.org][Aula 3: Tipos de dados]] ([[https://youtu.be/iMiRzZCU7hE][vídeo]]) ([[./exercicios/03/README.org][exercícios]])
|
- 17.03.2025 [[./aulas/03-tipos-de-dados/README.org][Aula 3: Tipos de dados]] ([[https://youtu.be/iMiRzZCU7hE][vídeo]]) ([[./exercicios/03/README.org][exercícios]])
|
||||||
- 19.03.2025 [[./aulas/04-variaveis/README.org][Aula 4: Variaveis e ponteiros]] ([[https://youtu.be/i7RKtMgSSrM][vídeo]]) ([[./exercicios/04/README.org][exercícios]])
|
- 19.03.2025 [[./aulas/04-variaveis/README.org][Aula 4: Variaveis e ponteiros]] ([[https://youtu.be/i7RKtMgSSrM][vídeo]]) ([[./exercicios/04/README.org][exercícios]])
|
||||||
- 21.03.2025 [[./aulas/05-controle/README.org][Aula 5: Estruturas de controle de fluxo]] ([[https://youtu.be/9dvDL7FbYKY][vídeo]]) ([[./exercicios/05/README.org][exercícios]])
|
- 21.03.2025 [[./aulas/05-controle/README.org][Aula 5: Estruturas de controle de fluxo]] ([[https://youtu.be/9dvDL7FbYKY][vídeo]]) ([[./exercicios/05/README.org][exercícios]])
|
||||||
|
- 26.03.2025 [[./aulas/06-vetores/README.org][Aula 6: Vetores]] ([[https://youtu.be/W5TGNQYFs4E][vídeo]]) ([[./exercicios/06/README.org][exercícios]])
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
||||||
// Função variádica (número indeterminado de argumentos)...
|
// Função variádica (número indeterminado de argumentos)...
|
||||||
float vf_avg(int count, ...);
|
float vf_avg(int count, ...);
|
||||||
|
|
||||||
|
@ -8,8 +9,6 @@ float vf_avg(int count, ...);
|
||||||
float cf_avg(float a, float b, float c, float d);
|
float cf_avg(float a, float b, float c, float d);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|
||||||
float nota1 = 7.5;
|
float nota1 = 7.5;
|
||||||
|
@ -35,9 +34,10 @@ int main(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Função comum...
|
||||||
|
float cf_avg(float a, float b, float c, float d) {
|
||||||
|
return (a + b + c + d) / 4;
|
||||||
|
}
|
||||||
|
|
||||||
// Função variádica...
|
// Função variádica...
|
||||||
float vf_avg(int count, ...) {
|
float vf_avg(int count, ...) {
|
||||||
|
@ -53,7 +53,3 @@ float vf_avg(int count, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Função comum...
|
|
||||||
float cf_avg(float a, float b, float c, float d) {
|
|
||||||
return (a + b + c + d) / 4;
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
* Aula 6: Vetores
|
* Aula 6: Vetores
|
||||||
|
|
||||||
[[][Vídeo desta aula]]
|
[[https://youtu.be/W5TGNQYFs4E][Vídeo desta aula]]
|
||||||
|
|
||||||
Vetores são estruturas de dados que agrupam valores do mesmo tipo na forma
|
Vetores são estruturas de dados que agrupam valores do mesmo tipo na forma
|
||||||
de listas.
|
de listas.
|
||||||
|
|
34
aulas/06-vetores/testes.c
Normal file
34
aulas/06-vetores/testes.c
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define NBIM 4
|
||||||
|
|
||||||
|
float favg(float *arr, int size) {
|
||||||
|
float sum = 0;
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
sum += arr[i];
|
||||||
|
}
|
||||||
|
return sum / size;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
float notas[NBIM];
|
||||||
|
|
||||||
|
notas[0] = 7.5;
|
||||||
|
notas[1] = 9.0;
|
||||||
|
notas[2] = 8.3;
|
||||||
|
notas[3] = 8.6;
|
||||||
|
|
||||||
|
float avg = favg(notas, NBIM);
|
||||||
|
|
||||||
|
puts("============");
|
||||||
|
|
||||||
|
for (int i = 0; i < NBIM; i++)
|
||||||
|
printf("Bim. %d: %.1f\n", i + 1, notas[i]);
|
||||||
|
|
||||||
|
puts("------------");
|
||||||
|
printf("Média : %.1f\n", avg);
|
||||||
|
puts("============");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -19,7 +19,7 @@
|
||||||
vetor = endereço na memória ↑ ↑ ↑ ↑ ↑
|
vetor = endereço na memória ↑ ↑ ↑ ↑ ↑
|
||||||
Total de 16 bytes +----- 4 bytes -----+----- 4 bytes -----+----- 4 bytes -----+----- 4 bytes -----+
|
Total de 16 bytes +----- 4 bytes -----+----- 4 bytes -----+----- 4 bytes -----+----- 4 bytes -----+
|
||||||
↑ ↑
|
↑ ↑
|
||||||
&vetor+0 &vetor+4 (*)
|
&vetor+0 &vetor+1 (*)
|
||||||
|
|
||||||
|
|
||||||
(*) Problema: acesso fora dos limites do vetor!
|
(*) Problema: acesso fora dos limites do vetor!
|
||||||
|
|
Loading…
Add table
Reference in a new issue