Upload files to "verifica_2"
This commit is contained in:
parent
ab29f02538
commit
70912ecbda
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
AUTORE: Manuel Vichi
|
||||
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
bool esco(int Sara, int Lara, int Luca) {
|
||||
return (Sara || Lara) && !Luca;
|
||||
}
|
||||
void stampaTabella() {
|
||||
for (int Sara = 0; Sara <= 8; Sara++) {
|
||||
cout << "Sara: ";
|
||||
if (Sara == 1)
|
||||
cout << "1";
|
||||
else
|
||||
cout << "0";
|
||||
cout << " | ";
|
||||
|
||||
for (int Lara = 0; Lara <= 1; Lara++) {
|
||||
cout << "Lara: ";
|
||||
if (Lara == 1)
|
||||
cout << "1";
|
||||
else
|
||||
cout << "0";
|
||||
cout << " | ";
|
||||
|
||||
for (int Luca = 0; Luca <= 1; Luca++) {
|
||||
bool risultato;
|
||||
if (Sara == 1 && Lara == 1) {
|
||||
risultato = Sara || Lara;
|
||||
} else if (Sara == 1 && Lara == 0) {
|
||||
risultato = Sara;
|
||||
} else if (Sara == 0 && Luca == 1) {
|
||||
risultato = false;
|
||||
} else if (Lara == 1 && Luca == 0) {
|
||||
risultato = Sara || Lara;
|
||||
} else if (Lara == 0 && Luca == 1) {
|
||||
risultato = false;
|
||||
} else {
|
||||
risultato = esco(Sara, Lara, Luca);
|
||||
}
|
||||
|
||||
cout << "Risultato: ";
|
||||
if (risultato == true)
|
||||
cout << "1";
|
||||
else
|
||||
cout << "0";
|
||||
|
||||
cout << " | ";
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
stampaTabella();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
AUTORE: Manuel Vichi
|
||||
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
void insertionSort(int arr[], int n) {
|
||||
for (int i = 1; i < n; i++) {
|
||||
int key = arr[i];
|
||||
int j = i - 1;
|
||||
|
||||
while (j >= 0 && arr[j] > key) {
|
||||
arr[j + 1] = arr[j];
|
||||
j--;
|
||||
}
|
||||
arr[j + 1] = key;
|
||||
}
|
||||
}
|
||||
int eliminaDuplicati(int arr[], int n) {
|
||||
int finalSize = n;
|
||||
for (int i = n; i > n/2; i--) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (arr[i] == arr[j]) {
|
||||
arr[j] = arr[i];
|
||||
finalSize--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return finalSize;
|
||||
}
|
||||
void printArray(int arr[], int n) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
cout << arr[i] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int v1[] = {1, 2, 2, 3, 4, 3, 5, 6, 6, 7};
|
||||
int n = sizeof(v1) / sizeof(v1[0]);
|
||||
printArray(v1,n);
|
||||
insertionSort(v1, n);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
void generaMatrice(int matrice[][10], int righe, int colonne)
|
||||
|
||||
int main() {
|
||||
srand(time(0)); // Inizializza il generatore di numeri casuali
|
||||
|
||||
int matrice[5][10]; // Matrice 5x10
|
||||
int righe = 5, colonne = 10;
|
||||
|
||||
// Genera e stampa la matrice casuale
|
||||
generaMatrice(matrice, righe, colonne);
|
||||
cout << "Matrice generata:" << endl;
|
||||
stampaMatrice(matrice, righe, colonne);
|
||||
|
||||
// Modifica le colonne 2 e 4 impostando tre elementi consecutivi successivi
|
||||
modificaColonne(matrice, righe);
|
||||
cout << "\nMatrice modificata (colonne 2 e 4 con valori successivi):" << endl;
|
||||
stampaMatrice(matrice, righe, colonne);
|
||||
|
||||
// Analizza e stampa le colonne con tre elementi consecutivi successivi
|
||||
cout << endl;
|
||||
stampaColonneConsecutive(matrice, righe, colonne);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue