mirror of
https://gitlab.com/blau_araujo/cblc.git
synced 2025-05-10 10:36:37 -03:00
Compare commits
No commits in common. "b48c7e8c4bd05dd4ddaa9dad6502fb8c094a4b63" and "34efb5e18b1ec1c670ede9124f63de38dfde2402" have entirely different histories.
b48c7e8c4b
...
34efb5e18b
2 changed files with 1 additions and 103 deletions
|
@ -30,4 +30,4 @@ qualquer distribuição.
|
|||
- 26.03.2025 [[./aulas/06-vetores/README.org][Aula 6: Vetores]] ([[https://youtu.be/W5TGNQYFs4E][vídeo]]) ([[./exercicios/06/README.org][exercícios]])
|
||||
- 28.03.2025 [[./aulas/07-vps/README.org][Aula 7: Vetores, ponteiros e strings]] ([[https://youtu.be/hhySl3ClTLE][vídeo]]) ([[./exercicios/07/README.org][exercícios]])
|
||||
- 31.03.2025 [[./aulas/08-processos/README.org][Aula 8: Processos e layout de memória]] ([[https://youtu.be/60bXYVCFoTI][vídeo]]) (sem exercícios)
|
||||
- 04.04.2025 [[./aulas/09-args/README.org][Aula 9: Argumentos e ambiente]] ([[https://youtu.be/uufnW60rg2Q][vídeo]]) ([[./exercicios/09/README.org][exercícios]])
|
||||
- 04.04.2025 [[./aulas/09-args/README.org][Aula 9: Argumentos e ambiente]] ([[https://youtu.be/uufnW60rg2Q][vídeo]]) (exercícios)
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
#+title: Curso Básico da Linguagem C
|
||||
#+subtitle: Exercícios
|
||||
#+author: Blau Araujo
|
||||
#+startup: show2levels
|
||||
#+options: toc:3
|
||||
|
||||
* Exercícios da aula 9: Argumentos e ambiente
|
||||
|
||||
- [[../../aulas/09-args/README.org][Anotações da aula]]
|
||||
- [[https://youtu.be/uufnW60rg2Q][Vídeo]]
|
||||
|
||||
** 1. Desafio: Programa =listenv=
|
||||
|
||||
Crie um programa que liste as variáveis exportadas para seu ambiente de duas
|
||||
formas:
|
||||
|
||||
*Sem argumentos:* lista todas as variáveis no ambiente...
|
||||
|
||||
#+begin_example
|
||||
:~$ listenv
|
||||
#+end_example
|
||||
|
||||
*Com nomes de variáveis:* lista apenas os valores das variáveis informadas...
|
||||
|
||||
#+begin_example
|
||||
:~$ listenv VAR1 VAR2 ...
|
||||
#+end_example
|
||||
|
||||
Para cada variável inexistente passada como argumento, imprimir na saída
|
||||
padrão de erros (=stderr=)...
|
||||
|
||||
#+begin_example
|
||||
:~$ listenv SHELL VAR2 VAR3
|
||||
/bin/bash
|
||||
VAR2 não está definida no ambiente
|
||||
VAR3 não está definida no ambiente
|
||||
#+end_example
|
||||
|
||||
** 2. Desafio: Programa =tconv=
|
||||
|
||||
Crie um programa que converta temperaturas segundo a sintaxe abaixo:
|
||||
|
||||
#+begin_example
|
||||
tconv 23.4c Converte 23.4 graus Celsius para Fahrenheit
|
||||
tconv 100f Converte 100 graus Fahrenheit para Celsius
|
||||
#+end_example
|
||||
|
||||
#+begin_quote
|
||||
A unidade deve ser indiferente à caixa de texto (~f = F~, ~c = C~).
|
||||
#+end_quote
|
||||
|
||||
** 3. Desafio: Programa =2fer=
|
||||
|
||||
Crie um programa que, para cada =NOME= recebido como argumento, imprima:
|
||||
|
||||
#+begin_example
|
||||
Um para NOME, um para mim.
|
||||
#+end_example
|
||||
|
||||
Se nenhum nome for passado, imprimir:
|
||||
|
||||
#+begin_example
|
||||
Um para você, um para mim.
|
||||
#+end_example
|
||||
|
||||
** 4. Desafio: Programa =fatp=
|
||||
|
||||
Escreva um programa que imprima os fatores primos de um número inteiro positivo
|
||||
maior do que 1 recebido como argumento.
|
||||
|
||||
#+begin_example
|
||||
:~$ fatp 90
|
||||
2 3 3 5
|
||||
:~$ fatp 36
|
||||
2 2 3 3
|
||||
:~$ fatp 43
|
||||
43 é primo!
|
||||
#+end_example
|
||||
|
||||
|
||||
** 5. Desafio: Programa =round=
|
||||
|
||||
Escreva um programa que, recebendo um número com ponto flutuante como argumento,
|
||||
faça o seu arredondamento das seguintes formas:
|
||||
|
||||
#+begin_example
|
||||
:~$ round 2.5
|
||||
3
|
||||
:~$ round 2.4
|
||||
2
|
||||
:~$ round -c 2.3
|
||||
3
|
||||
:~$ round -f 2.9
|
||||
2
|
||||
:~$ round -t 2.6
|
||||
2
|
||||
#+end_example
|
||||
|
||||
#+begin_quote
|
||||
As opções =-t= (/truncate/), =-f= (/floor/) e =-c= (/ceil/) podem ser escritos antes ou
|
||||
depois do número. As opções =-t= e =-f= são sinônimas.
|
||||
#+end_quote
|
Loading…
Add table
Reference in a new issue