[AED] aula01 added

--> Note that last exercise if not fully functional
This commit is contained in:
Tiago Garcia 2023-09-18 00:37:44 +01:00
parent ebec4498cd
commit 26f108f8bf
Signed by: TiagoRG
GPG Key ID: DFCD48E3F420DB42
20 changed files with 213 additions and 4 deletions

View File

@ -1,7 +1,7 @@
# 1º Semestre
## Todo o material das cadeiras do 1º semestre do 2º ano:
- [Algorítmos e Estruturas de Dados](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/aed)
- [Algoritmos e Estruturas de Dados](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/aed)
- [Arquiteturas de Computadores 1](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/ac1)
- [Redes de Comunicação](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/rc1)
- [Mecânica e Campo Eletromagnético](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/mce)

View File

@ -1,4 +1,4 @@
# Algorítmos e Estruturas de Dados
# Algoritmos e Estruturas de Dados
### Projetos + resoluções de exercícios organizados por aulas
### Linguagem usada: C

Binary file not shown.

BIN
2ano/1semestre/aed/aula01/ProgA Executable file

Binary file not shown.

View File

@ -0,0 +1,36 @@
#include <stdio.h>
int arr_length(int arr[])
{
int count = 0;
for(int i=0; arr[i]!='\0'; i++) {
count++;
}
return count;
}
void print_array(char s[], int arr[]) {
printf("%s:\n", s);
for (int i=0; i<arr_length(arr); i++) {
printf("%d ", arr[i]);
}
printf("\n");
}
void cumSum(int a[], int b[]) {
int c = 0;
for (int i=0; i<arr_length(a); i++) {
c += a[i];
b[i] = c;
}
}
int main() {
int a[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
print_array("a", a);
int b[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
//print_array("b", b);
cumSum(a, b);
print_array("b", b);
}

View File

@ -0,0 +1,33 @@
/*
Crie um programa em C equivalente a este em Java.
*/
public class ProgA {
public static void main(String[] args) {
int[] a = {31,28,31,30,31,30,31,31,30,31,30,31};
printArray("a", a);
int[] b = new int[12];
cumSum(a, b);
printArray("b", b);
}
public static void printArray(String s, int[] a) {
System.out.println(s + ":");
for (int i=0; i<a.length; i++) {
System.out.print(a[i]+" ");
}
System.out.println();
}
public static void cumSum(int[] a, int[] b) {
int c = 0;
for (int i=0; i<a.length; i++) {
c += a[i];
b[i] = c;
}
}
}

BIN
2ano/1semestre/aed/aula01/hello_x Executable file

Binary file not shown.

View File

@ -0,0 +1,10 @@
#include <stdio.h>
#include <string.h>
int main() {
char name[50];
scanf("Test: %s", name);
printf("Hello, %s", name);
return 0;
}

Binary file not shown.

View File

@ -0,0 +1,13 @@
#include <stdio.h>
int main() {
printf("Sizeof(void *) ...... %ld\n", sizeof(void *));
printf("Sizeof(void) ........ %ld\n", sizeof(void));
printf("Sizeof(char) ........ %ld\n", sizeof(char));
printf("Sizeof(short) ....... %ld\n", sizeof(short));
printf("Sizeof(int) ......... %ld\n", sizeof(int));
printf("Sizeof(long) ........ %ld\n", sizeof(long));
printf("Sizeof(long long) ... %ld\n", sizeof(long long));
printf("Sizeof(float) ....... %ld\n", sizeof(float));
printf("Sizeof(double) ...... %ld\n", sizeof(double));
}

Binary file not shown.

View File

@ -0,0 +1,8 @@
#include<stdio.h>
int main() {
printf("Hello world!\n");
printf("%ld\n", __STDC_VERSION__);
return 0;
}

BIN
2ano/1semestre/aed/aula01/table1 Executable file

Binary file not shown.

View File

@ -0,0 +1,16 @@
#include <math.h>
#include <stdio.h>
int main() {
int lines;
printf("Número de linhas: ");
scanf("%d", &lines);
printf("%5s | %10s | %s \n", "Number", "Square", "Square Root");
for(int i = 1; i<=lines; i++) {
printf("%6d | %10d | %.4f\n", i, i*i, sqrt(i));
}
return 0;
}

BIN
2ano/1semestre/aed/aula01/table2 Executable file

Binary file not shown.

View File

@ -0,0 +1,20 @@
#include <math.h>
#include <stdio.h>
#define to_rad(deg) ((deg)*M_PI/180)
int main() {
FILE *output_file;
output_file = fopen("table2.txt", "w");
printf("%3s | %s | %s\n", "ang", "sin(ang)", "cos(ang)");
fprintf(output_file, "%3s | %s | %s\n", "ang", "sin(ang)", "cos(ang)");
for (int i = 0; i < 360; i+=5) {
printf("%3d | %.5f | %.5f\n", i, sin(to_rad(i)), cos(to_rad(i)));
fprintf(output_file, "%3d | %.5f | %.5f\n", i, sin(to_rad(i)), cos(to_rad(i)));
}
fclose(output_file);
return 0;
}

View File

@ -0,0 +1,73 @@
ang | sin(ang) | cos(ang)
0 | 0.00000 | 1.00000
5 | 0.08716 | 0.99619
10 | 0.17365 | 0.98481
15 | 0.25882 | 0.96593
20 | 0.34202 | 0.93969
25 | 0.42262 | 0.90631
30 | 0.50000 | 0.86603
35 | 0.57358 | 0.81915
40 | 0.64279 | 0.76604
45 | 0.70711 | 0.70711
50 | 0.76604 | 0.64279
55 | 0.81915 | 0.57358
60 | 0.86603 | 0.50000
65 | 0.90631 | 0.42262
70 | 0.93969 | 0.34202
75 | 0.96593 | 0.25882
80 | 0.98481 | 0.17365
85 | 0.99619 | 0.08716
90 | 1.00000 | 0.00000
95 | 0.99619 | -0.08716
100 | 0.98481 | -0.17365
105 | 0.96593 | -0.25882
110 | 0.93969 | -0.34202
115 | 0.90631 | -0.42262
120 | 0.86603 | -0.50000
125 | 0.81915 | -0.57358
130 | 0.76604 | -0.64279
135 | 0.70711 | -0.70711
140 | 0.64279 | -0.76604
145 | 0.57358 | -0.81915
150 | 0.50000 | -0.86603
155 | 0.42262 | -0.90631
160 | 0.34202 | -0.93969
165 | 0.25882 | -0.96593
170 | 0.17365 | -0.98481
175 | 0.08716 | -0.99619
180 | 0.00000 | -1.00000
185 | -0.08716 | -0.99619
190 | -0.17365 | -0.98481
195 | -0.25882 | -0.96593
200 | -0.34202 | -0.93969
205 | -0.42262 | -0.90631
210 | -0.50000 | -0.86603
215 | -0.57358 | -0.81915
220 | -0.64279 | -0.76604
225 | -0.70711 | -0.70711
230 | -0.76604 | -0.64279
235 | -0.81915 | -0.57358
240 | -0.86603 | -0.50000
245 | -0.90631 | -0.42262
250 | -0.93969 | -0.34202
255 | -0.96593 | -0.25882
260 | -0.98481 | -0.17365
265 | -0.99619 | -0.08716
270 | -1.00000 | -0.00000
275 | -0.99619 | 0.08716
280 | -0.98481 | 0.17365
285 | -0.96593 | 0.25882
290 | -0.93969 | 0.34202
295 | -0.90631 | 0.42262
300 | -0.86603 | 0.50000
305 | -0.81915 | 0.57358
310 | -0.76604 | 0.64279
315 | -0.70711 | 0.70711
320 | -0.64279 | 0.76604
325 | -0.57358 | 0.81915
330 | -0.50000 | 0.86603
335 | -0.42262 | 0.90631
340 | -0.34202 | 0.93969
345 | -0.25882 | 0.96593
350 | -0.17365 | 0.98481
355 | -0.08716 | 0.99619

Binary file not shown.

View File

@ -2,7 +2,7 @@
## Todo o material das cadeiras do 2º ano:
### [1º Semestre](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre)
- [Algor&iacute;tmos e Estruturas de Dados](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/aed)
- [Algoritmos e Estruturas de Dados](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/aed)
- [Arquiteturas de Computadores 1](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/ac1)
- [Redes de Comunicação](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/rc1)
- [Mecânica e Campo Eletromagnético](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/mce)

View File

@ -23,7 +23,7 @@ Pode usar todo o material/código/etc. disponibilizado mas é expressamente proi
## [2º Ano](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre)
- ### [1º Semestre](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre)
- [Algor&iacute;tmos e Estruturas de Dados](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/aed)
- [Algoritmos e Estruturas de Dados](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/aed)
- [Arquiteturas de Computadores 1](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/ac1)
- [Redes de Comunicação](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/rc1)
- [Mecânica e Campo Eletromagnético](https://github.com/TiagoRG/uaveiro-leci/tree/master/2ano/1semestre/mce)