Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: merge dev into master #7

Merged
merged 3 commits into from Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions .vscode/settings.json
Expand Up @@ -3,13 +3,6 @@
"justfile": "makefile"
},
"material-icon-theme.folders.associations": {
"C": "scripts",
"conditional_structures": "tasks",
"sequential_structures": "tasks",
"repetition_structures": "tasks",
"functions": "tasks",
"vectors": "tasks",
"matrix": "tasks",
"strings": "tasks"
"C": "scripts"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions apps/C/pointers/1.c
@@ -0,0 +1,32 @@
#include <stdio.h>

#define LEN 10

int negativos(int *vet, int len);

int main() {
// Write C code here
int vet[LEN] = {-4, -2, -5, 0, -10, 2, 9, 12};

int *point = vet;

// printf("%d", point);

int num_negativos = negativos(point, LEN);

printf("Total de números negativos no array: %d\n", num_negativos);

return 0;
}

int negativos(int *vet, int len) {
int negativos_count = 0;

for (int i = 0; i < len; i++) {
if (*(vet + i) < 0) {
negativos_count++;
}
}

return negativos_count;
}
17 changes: 17 additions & 0 deletions apps/C/pointers/10.c
@@ -0,0 +1,17 @@
#include <stdio.h>

void main() {
int x, y = 0;
int *p = &y;

x = *p;
x = 10;
x--;

printf("%d\n", *p); // 0

*p += x;
printf("%d\n", y); // 9

printf("%d\n", &x == p); // False
}
20 changes: 20 additions & 0 deletions apps/C/pointers/11.c
@@ -0,0 +1,20 @@
#include <stdio.h>

#define PROD 30

void main() {
float v[PROD];

for (int i = 0; i < PROD; i++) {
printf("Digite o valor do %dº produto: ", i + 1);
scanf("%f", &v[i]);

v[i] += v[i] * 0.08;
}

printf("Valor dos produtos:\n");

for (int i = 0; i < PROD; i++) {
printf("\t%.2f\n", v[i]);
}
}
24 changes: 24 additions & 0 deletions apps/C/pointers/12.c
@@ -0,0 +1,24 @@
#include <stdio.h>

#define MAX_LEN 100

int total_words(char *str) {
int count = 0;

for (int i = 0; str[i] != '\0'; i++) {
if (str[i] == ' ') {
count++;
}
}

return count + 1;
}

void main() {
char str[MAX_LEN];

printf("Digite uma frase: ");
fgets(str, MAX_LEN, stdin);

printf("A frase tem %d palavras.\n", total_words(str));
}
25 changes: 25 additions & 0 deletions apps/C/pointers/2.c
@@ -0,0 +1,25 @@
#include <stdio.h>

// int main() {
// int x;
// int* p = &x;
//
// printf("Digite um número: ");
// scanf("%d", *p); - Scanf cannot be assigned to it value
//
// printf("%d", x);
//
// return 0;
//}

int main() {
int x;
int *p = &x;

printf("Digite um número: ");
scanf("%d", p); // Fix

printf("%d", x);

return 0;
}
32 changes: 32 additions & 0 deletions apps/C/pointers/3.c
@@ -0,0 +1,32 @@
#include <stdio.h>

#define LEN 10

int get_bigger(int *vet, int length, int *pos);

int main() {
int vet[LEN] = {0, 10, 412, 1, 529, -329, 5321, -31230, 23};
int *point_vet = &vet;
int pos = 0;

int bigger = get_bigger(point_vet, LEN, &pos);

printf("Maior número: %d\n", bigger);
printf("Posição no array: %d\n", pos);

return 0;
}

int get_bigger(int *vet, int len, int *pos) {
int bigger = 0;

for (int i = 0; i < len; i++) {
if (*(vet + i) > bigger) {
bigger = *(vet + i);

*pos = i;
}
}

return bigger;
}
35 changes: 35 additions & 0 deletions apps/C/pointers/4.c
@@ -0,0 +1,35 @@
#include <stdio.h>

#define LEN 5

int find(int *vet, int len, int *less, int *bigger);

void main() {
int vet[LEN] = {4213, 232, 3412321, 432, 5543};
int *point_vet = &vet;
int less, bigger;

find(point_vet, LEN, &less, &bigger);

printf("Menor número: %d\n", less);
printf("Maior número: %d\n", bigger);
}

int find(int *vet, int len, int *less, int *bigger) {
for (int i = 0; i < len; i++) {
if (i == 0) {
*less = *(vet + i);
*bigger = *(vet + i);
}

if (*(vet + i) > less) {
*less = *(vet + i);
}

if (*(vet + i) < bigger) {
*bigger = *(vet + i);
}
}

return 0;
}
18 changes: 18 additions & 0 deletions apps/C/pointers/5.c
@@ -0,0 +1,18 @@
// (a) Syntax error
// (b) Should be using &pf in scanf func
// (c) Not effective lecture of f float value
// -> (d) Effective lecture of f float value
// (e) None of the above

#include <stdio.h>

int main() {
float f;
float *pf;

pf = &f;

scanf("%f", pf);

printf("%f", *pf);
}
20 changes: 20 additions & 0 deletions apps/C/pointers/6.c
@@ -0,0 +1,20 @@
#include <stdio.h>

void reverseSentence();

void main() {
printf("Enter a frase: ");

reverseSentence();
}

void reverseSentence() {
char c;

scanf("%c", &c);

if (c != '\n') {
reverseSentence();
printf("%c", c);
}
}
30 changes: 30 additions & 0 deletions apps/C/pointers/7.c
@@ -0,0 +1,30 @@
#include <stdio.h>

#define LEN 4

void main() {
int m[LEN][LEN];

for (int i = 0; i < LEN; i++) {
for (int j = 0; j < LEN; j++) {
printf("Digite o valor da linha %d e coluna %d: ", i + 1, j + 1);
scanf("%d", &m[i][j]);
}
}

int c = 0;
int x;

printf("Digite o valor que deseja procurar: ");
scanf("%d", &x);

for (int i = 0; i < LEN; i++) {
for (int j = 0; j < LEN; j++) {
if (m[i][j] == x) {
c++;
}
}
}

printf("O valor foi encontrado %d vezes\n", c);
}
11 changes: 11 additions & 0 deletions apps/C/pointers/8.c
@@ -0,0 +1,11 @@
// y = p1 == p2 // False
// p1 += p2 // Error
// x = (*p1) - (*p2) // -5
// p1++ // Memory block address + 4
// x = p1 || p2 // True

void main() {
int x = 5, y = 10;
int *p1 = &x;
int *p2 = &y;
}
10 changes: 10 additions & 0 deletions apps/C/pointers/9.c
@@ -0,0 +1,10 @@
#include <stdio.h>
#include <string.h>

void main() {
char v[] = "não gosto de programar!";

for (int i = 5; i < strlen(v); i++) {
printf("%c", *(v + i));
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes