chore: vscode/uni exercises

This commit is contained in:
Guz
2026-04-11 10:11:37 -03:00
parent e05749d7fb
commit 91c7bad66c
5 changed files with 162 additions and 14 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.direnv
build
*.exe

51
.vscode/tasks.json vendored
View File

@@ -1,15 +1,38 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile",
"type": "shell",
"command": "clang -std=c23 -glldb -fstandalone-debug ${relativeFile} -o ${fileBasenameNoExtension}"
},
{
"label": "Clean",
"type": "shell",
"command": "rm ${fileBasenameNoExtension}"
}
]
}
"version": "2.0.0",
"tasks": [
{
"label": "Compile",
"type": "shell",
"command": "clang -std=c23 -glldb -fstandalone-debug ${relativeFile} -o ${fileBasenameNoExtension}"
},
{
"label": "Clean",
"type": "shell",
"command": "rm ${fileBasenameNoExtension}"
},
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\msys64\\mingw64\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
]
}

62
strings/ex01.c Normal file
View File

@@ -0,0 +1,62 @@
#include <stdio.h>
int main(int argc, char const *argv[])
{
while (1)
{
int months = 0;
printf("Digite a quantidade de índices de audência que serão digitados:\n");
if (scanf("%d", &months) != 1)
{
return 1;
}
if (months < 0)
{
printf("Números negativos não são validos!");
return 1;
}
double input, last = 0, sum = 0;
int growing = 1;
for (int i = 1; i <= months; i++)
{
printf("Digite o índice do mês %d:\n", i);
if (scanf("%lf", &input) != 1)
{
return 1;
}
if (input < 0)
{
printf("Números negativos não são validos!");
return 1;
}
sum += input;
if (last > input)
{
growing = 0;
}
last = input;
}
double avarage = sum / months;
if (growing == 1)
{
printf("AUDIÊNCIA SEMPRE CRESCENTE. Média de audiência: %.1f\n", avarage);
}
else
{
printf("AUDIÊNCIA NEM SEMPRE CRESCENTE. Média de audiência: %.1f\n", avarage);
}
printf("Continuar? (S/N)\n");
char c;
scanf(" %c", &c);
if (c != 'S')
{
return 0;
}
}
}

33
strings/ex02.c Normal file
View File

@@ -0,0 +1,33 @@
#include <stdio.h>
int main(int argc, char const *argv[])
{
while (1)
{
int input, sum = 0;
printf("Digite um número (digite -1 para sair):\n");
if (scanf("%d", &input) != 1) {
return 1;
}
if (input < 0 ) {
return 0;
}
for (int i = 1; i < input; i++)
{
if (input % i == 0) {
sum += i;
}
}
if (sum == input) {
printf("%d é um número perfeito!\n", input);
} else {
printf("%d não é um número perfeito!\n", input);
}
}
return 0;
}

29
strings/ex03.c Normal file
View File

@@ -0,0 +1,29 @@
#include <stdio.h>
int main(int argc, char const *argv[])
{
int input;
printf("Digite um número:\n");
if (scanf("%d", &input) != 1) {
return 1;
}
if (input < 0) {
printf("Digite um número positivo!");
return 1;
}
int k = 1;
for (int i = 0; i < input; i++)
{
for (int j = 0; j < k; j++)
{
printf("* ");
}
printf("\n");
k++;
}
return 0;
}