Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Exercicio 1:
- Resposta correta : (A)
- Código:
- 1. for (i = 0 to 29) {
- 2. for (j = 0 to 39) {
- 3. if (a[i] == b[j]) {
- 4. print(a[i]);
- 5. }
- 6. }
- 7. }
- ////////////////////////////////////////////
- Exercicio 2:
- 3. if (a[i] == b[j]) {
- 4. print (a[i]);
- 5. }
- ////////////////////////////////////////////
- Exercicio 3:
- Cálculo feito:
- -a * b++ - c--
- = -1 * 2++ - 0--
- = -2 - 0
- = -2
- Então, o resultado da expressão -a * b++ - c-- é -2, correspondendo à opção (E).
- ////////////////////////////////////////////
- EXERCICIO 4:
- A: A melhor opção para este problema é uma matriz. por ser uma tabela organizada em linhas e colunas, ideal para representar a plantação de café.
- B:
- int contarFalhasPlantio(int matriz[3][5], int linhas, int colunas) {
- int falhas = 0;
- for (int linha = 0; linha < linhas; linha++) {
- for (int coluna = 0; coluna < colunas; coluna++) {
- if (matriz[linha][coluna] == 0) {
- falhas++;
- }
- }
- }
- return falhas;
- }
- int main() {
- int plantacao[3][5] = {
- {1, 0, 1, 0, 0},
- {0, 1, 0, 1, 0},
- {1, 0, 0, 0, 1}
- };
- int linhas = 3;
- int colunas = 5;
- int totalFalhas = contarFalhasPlantio(plantacao, linhas, colunas);
- printf("Total de falhas de plantio: %d\n", totalFalhas);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement