feat: Initial commit

This commit is contained in:
2024-03-22 17:14:57 +01:00
parent dc83234df1
commit db9bafe755
45 changed files with 1996 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
Caratterizzata da un pass| c:25
ato turbolento, in | c:19
epoca medievale Rouen fu | c:25
devastata piu' volte | c:21
da incendi ed epidemie e | c:25
durante la Guerra | c:18
dei Cent' Anni fu occupat| c:25
a dagli inglesi. | c:18
Nel **** nella sua piazza| c:25
centrale la giovane | c:21
Giovanna d' Arco ( Jeanne| c:25
d' Arc) fu processata | c:23
per eresia e arsa sul rog| c:25
o! Durante la seconda | c:22
guerra mondiale gli Allea| c:25
ti bombardarono | c:16
ampie zone della citta' ,| c:25
soprattutto il | c:16
quartiere che si estende | c:25
a sud della cattedrale. | c:25
<EFBFBD> | c:2

108
Laboratorio 3/esercizio1.c Normal file
View File

@@ -0,0 +1,108 @@
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
#define INPUT_FILE "./input.txt"
#define OUTPUT_FILE "./testo.txt"
void writeChar(FILE *fout, int * charInLine, int * written, char chr, bool isOrig) {
if (chr != '\n') {
fputc(chr, fout);
} else {
for (int i = *charInLine; i <= 24; i++) {
fputc(' ', fout);
}
}
if (*charInLine >= 24 || chr == '\n') {
fprintf(fout, "| c:%d \n", *written + 1);
*charInLine = 0;
*written = 0;
} else {
if (isOrig) {
*written += 1;
}
*charInLine += 1;
}
}
void elabora(FILE *fin, FILE *fout) {
char lastChar, currChar, buf;
int count, i;
int charInLine = 0, written = 0;
bool requiresSpace = false;
bool requiresCaps = false;
while (!feof(fin))
{
buf = fgetc(fin);
if (feof(fin))
break;
currChar = buf; // This is done to avoid havind EOF char in currChar.
if (requiresSpace) {
if (currChar != ' ') {
writeChar(fout, &charInLine, &written, ' ', false);
}
requiresSpace = false;
}
if (requiresCaps && isalpha(currChar)) {
if (currChar >= 97 && currChar <= 122) {
currChar -= 32;
}
requiresCaps = false;
}
if (isdigit(currChar)) {
writeChar(fout, &charInLine, &written, '*', true);
} else {
writeChar(fout, &charInLine, &written, currChar, true);
}
if (currChar == '.' || currChar == ',' ||currChar == ';' ||currChar == ':' ||currChar == '!' ||currChar == '?' ||currChar == '\''||currChar == '('||currChar == ')') {
requiresSpace = true;
}
if (currChar == '.' ||currChar == '!' ||currChar == '?') {
requiresCaps = true;
}
}
// Add '\n' at the end of the file if not present
if (currChar != '\n') {
writeChar(fout, &charInLine, &written, '\n', false);
}
}
int main()
{
FILE *fp_read, *fp_write;
fp_read = fopen(INPUT_FILE, "r");
fp_write = fopen(OUTPUT_FILE, "w");
if (fp_read == NULL)
{
printf("Error opening file\n");
return 1;
}
if (fp_write == NULL)
{
printf("Error opening file\n");
return 2;
}
elabora(fp_read, fp_write);
fclose(fp_read);
fclose(fp_write);
return 0;
}

View File

@@ -0,0 +1,71 @@
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
#define INPUT_FILE "./numeri.txt"
int max(int a, int b)
{
if (a > b) {
return a;
}
return b;
}
int min(int a, int b)
{
if (a < b) {
return a;
}
return b;
}
int main()
{
FILE *fp_read;
fp_read = fopen(INPUT_FILE, "r");
if (fp_read == NULL)
{
printf("Error opening file\n");
return 1;
}
int x, y, a;
int maxVal, minVal, scartati = 0;
if (fscanf(fp_read, " %d", &x) == EOF || fscanf(fp_read, " %d",& y) == EOF) {
fclose(fp_read);
return 1; // Terminate if there are only two numbers
}
minVal = min(x, y);
maxVal = max(x, y);
while (!feof(fp_read))
{
if (fscanf(fp_read, " %d", &a) == EOF) {
break;
}
if (x + y != a && x - y != a && x * y != a && (y==0 || x / y != a )) {
scartati++;
continue;
}
minVal = min(minVal, a);
maxVal = max(maxVal, a);
x = y;
y = a;
}
printf("Numero massimo: %d\nNumero minimo: %d\nNumeri scartati: %d\n", maxVal, minVal, scartati);
fclose(fp_read);
return 0;
}

9
Laboratorio 3/input.txt Normal file
View File

@@ -0,0 +1,9 @@
Caratterizzata da un passato turbolento, in
epoca medievale Rouen fu devastata piu' volte
da incendi ed epidemie e durante la Guerra
dei Cent'Anni fu occupata dagli inglesi.
nel 1431 nella sua piazza centrale la giovane
Giovanna d'Arco (Jeanne d'Arc) fu processata
per eresia e arsa sul rogo!durante la seconda
guerra mondiale gli Alleati bombardarono
ampie zone della citta', soprattutto il quartiere che si estende a sud della cattedrale.

10
Laboratorio 3/numeri.txt Normal file
View File

@@ -0,0 +1,10 @@
12
3
4
7 -3
0
4
1
3
3 9
11

20
Laboratorio 3/testo.txt Normal file
View File

@@ -0,0 +1,20 @@
Caratterizzata da un pass| c:25
ato turbolento, in | c:19
epoca medievale Rouen fu | c:25
devastata piu' volte | c:21
da incendi ed epidemie e | c:25
durante la Guerra | c:18
dei Cent' Anni fu occupat| c:24
a dagli inglesi. | c:17
Nel **** nella sua piazza| c:25
centrale la giovane | c:21
Giovanna d' Arco ( Jeanne| c:23
d' Arc) fu processata | c:22
per eresia e arsa sul rog| c:25
o! Durante la seconda | c:21
guerra mondiale gli Allea| c:25
ti bombardarono | c:16
ampie zone della citta' ,| c:24
soprattutto il quartiere| c:25
che si estende a sud del| c:25
la cattedrale. | c:15