summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/biblioteca.cc57
-rw-r--r--cpp/compito.cpp94
-rw-r--r--cpp/crittografia.cc89
-rw-r--r--cpp/numeri.cc50
-rw-r--r--cpp/palindromo.cc25
-rw-r--r--cpp/substring.cc22
6 files changed, 0 insertions, 337 deletions
diff --git a/cpp/biblioteca.cc b/cpp/biblioteca.cc
deleted file mode 100644
index 85cd80f..0000000
--- a/cpp/biblioteca.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <iostream>
-#include <fstream>
-#include <sstream>
-#include <time.h>
-
-using namespace std;
-
-int main(void)
-{
- ifstream filein;
- ofstream fileout;
-
- filein.open("input.txt");
- fileout.open("output.txt");
-
- time_t rawtime;
- struct tm * timeinfo;
-
- int num[4], i = 0, j = 1, diff, tot[2];
- char ch;
- string cc;
-
- while(!filein.eof())
- {
- filein.get(ch);
- if(ch != ' '){
- cc+=ch;
- istringstream(cc) >> num[i];
- }else {
- i++;
- cc = "";
- }
- }
-
- time(&rawtime);
- timeinfo = localtime(&rawtime);
-
- for(i = 0; i < 2; i++){
- timeinfo->tm_year = 2001-1900;
- timeinfo->tm_mon = num[j]-1;
- timeinfo->tm_mday = num[j-1];
-
- mktime(timeinfo);
-
- tot[i] = timeinfo->tm_yday+1;
- j = 3;
- }
-
- diff = tot[1] - tot[0];
-
- fileout << diff;
-
- filein.close();
- fileout.close();
-
- return 0;
-}
diff --git a/cpp/compito.cpp b/cpp/compito.cpp
deleted file mode 100644
index 205dc59..0000000
--- a/cpp/compito.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#include <iostream>
-#define N 5
-
-using namespace std;
-
-struct puntiVendita {
- string citta;
- float entrate;
- float uscite;
-};
-
-struct puntiVendita pV[N];
-bool utili(struct puntiVendita p);
-void carica();
-void ord();
-void visualizza();
-
-int main()
-{
- carica();
-
- for(auto i : pV) {
- if(!utili(i))
- cout << "Attenzione -> " << i.citta << endl;
- }
-
- ord();
- visualizza();
-
- return 0;
-}
-
-bool utili(struct puntiVendita p)
-{
- return ((p.uscite > p.entrate) ? false : true);
-}
-
-void carica()
-{
- pV[0].citta = "Catania";
- pV[0].entrate = 380;
- pV[0].uscite = 245;
- pV[1].citta = "Ragusa";
- pV[1].entrate = 231;
- pV[1].uscite = 175;
- pV[2].citta = "Siracusa";
- pV[2].entrate = 214;
- pV[2].uscite = 227;
- pV[3].citta = "Messina";
- pV[3].entrate = 294;
- pV[3].uscite = 189;
- pV[4].citta = "Enna";
- pV[4].entrate = 145;
- pV[4].uscite = 175;
-}
-
-void ord()
-{
- struct puntiVendita t;
- bool s;
- int last = N-1;
-
- do {
- s = false;
-
- for(int i = 0; i < last; i++) {
- if(pV[i].entrate > pV[i+1].entrate) {
- t.citta = pV[i].citta;
- t.entrate = pV[i].entrate;
- t.uscite = pV[i].uscite;
-
- pV[i].citta = pV[i+1].citta;
- pV[i].entrate = pV[i+1].entrate;
- pV[i].uscite = pV[i+1].uscite;
-
-
- pV[i+1].citta = t.citta;
- pV[i+1].entrate = t.entrate;
- pV[i+1].uscite = t.uscite;
-
- s = true;
- }
- }
-
- last--;
- } while(s);
-}
-
-void visualizza()
-{
- for(auto i : pV) {
- cout << i.entrate << endl;
- }
-}
diff --git a/cpp/crittografia.cc b/cpp/crittografia.cc
deleted file mode 100644
index d448b86..0000000
--- a/cpp/crittografia.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-#include <iostream>
-#include <string>
-#include <sstream>
-#include <fstream>
-#include <cstring>
-
-using namespace std;
-
-void converti(char *str, int size);
-void vocalic(char *str, int size);
-
-char consonantiMin[] = {'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','z'};
-char consonantiMax[] = {'B','C','D','F','G','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Z'};
-
-int main()
-{
- ifstream in;
- ofstream out;
-
- in.open("input.txt");
- out.open("output.txt");
-
- int N;
- string ca;
-
- getline(in, ca);
- istringstream(ca) >> N;
-
- for(int i = 0; i < N; i++){
- getline(in, ca);
- char *c = new char[ca.length() + 1];
- strcpy(c, ca.c_str());
- converti(c, ca.length() + 1);
- out << c << endl;
- delete[] c;
- }
-
- in.close();
- out.close();
-
- return 0;
-}
-
-void vocalic(char *str, int i)
-{
- if(str[i] == 'a') str[i] = 'e';
- else if(str[i] == 'e') str[i] = 'i';
- else if(str[i] == 'i') str[i] = 'o';
- else if(str[i] == 'o') str[i] = 'u';
- else if(str[i] == 'u') str[i] = 'y';
- else if(str[i] == 'y') str[i] = 'a';
- else if(str[i] == 'A') str[i] = 'E';
- else if(str[i] == 'E') str[i] = 'I';
- else if(str[i] == 'I') str[i] = 'O';
- else if(str[i] == 'O') str[i] = 'U';
- else if(str[i] == 'U') str[i] = 'Y';
- else if(str[i] == 'Y') str[i] = 'A';
- else if(str[i] == 'z') str[i] = 'b';
- else if(str[i] == 'Z') str[i] = 'B';
- else if(str[i] == '0') str[i] = '1';
- else if(str[i] == '1') str[i] = '2';
- else if(str[i] == '2') str[i] = '3';
- else if(str[i] == '3') str[i] = '4';
- else if(str[i] == '4') str[i] = '5';
- else if(str[i] == '5') str[i] = '6';
- else if(str[i] == '6') str[i] = '7';
- else if(str[i] == '7') str[i] = '8';
- else if(str[i] == '8') str[i] = '9';
- else if(str[i] == '9') str[i] = '0';
-}
-
-void converti(char *str, int size)
-{
- bool cpres = false;
- for(int i = 0; i < size-1; i++){
- int s=1;
- vocalic(str,i);
- for(unsigned int j = 0; j < sizeof consonantiMin; j++){
- if(str[i] == consonantiMin[j] || str[i] == consonantiMax[j]){
- cpres = true;
- if(str[i]+1 == 'A' || str[i]+1 == 'E' || str[i]+1 == 'I' || str[i]+1 == 'O' || str[i]+1 == 'U' || str[i]+1 == 'Y' ||
- str[i]+1 == 'a' || str[i]+1 == 'e' || str[i]+1 == 'i' || str[i]+1 == 'o' || str[i]+1 == 'u' || str[i]+1 == 'y') s = 2;
- else s = 1;
- }
- }
- if(cpres == true) str[i]+=s;
- cpres = false;
- }
-}
diff --git a/cpp/numeri.cc b/cpp/numeri.cc
deleted file mode 100644
index ec2d2d4..0000000
--- a/cpp/numeri.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-
-int main(void)
-{
- fstream file;
- file.open("dati.dat");
-
- typedef unsigned short int size_t;
-
- size_t a, b, c, seq = 0, tot = 0, num;
- char stringa[] = "12312312312";
- char l;
- while(true)
- {
- cout << "3 numeri: ";
- cin >> a >> b >> c;
- if(a >= 0 && a <= 9 && b >= 0 && b <= 9 && c >= 0 && c <= 9){
- if(a != b && b != c && a != c) break;
- }
- }
-
- file << a << endl;
- file << b << endl;
- file << c << endl;
- file << stringa << endl;
- file.seekg(5, file.beg);
-
- while(!file.eof())
- {
- file.get(l);
- num = l - '0';
- if(seq == 0) {
- if(num == a) seq++;
- } else if(seq == 1) {
- if(num == b) seq++;
- } else if(seq == 2) {
- if(num == c) seq++;
- }
-
- if(seq == 3) { tot++; seq = 0; }
- }
-
- cout << "\n" << tot;
- file.close();
-
- return 0;
-}
diff --git a/cpp/palindromo.cc b/cpp/palindromo.cc
deleted file mode 100644
index 1cb19a2..0000000
--- a/cpp/palindromo.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// ConsoleApplication1.cpp : definisce il punto di ingresso dell'applicazione console.
-//
-#include "stdafx.h"
-#include <iostream>
-
-using namespace std;
-
-bool palindromo(int i, int j, char str[])
-{
- if (i >= j) return true;
- else if (str[i] == str[j]) return palindromo(i + 1, j - 1, str);
- else return false;
-}
-
-int main()
-{
- char parola[] = "onorarono";
-
- cout << ( (palindromo(0, sizeof parola - 2, parola) == 1) ? "E' palindromo" : "Non e' palindromo" ) << endl;
-
- cin.get();
-
- return 0;
-}
-
diff --git a/cpp/substring.cc b/cpp/substring.cc
deleted file mode 100644
index 55aa319..0000000
--- a/cpp/substring.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <iostream>
-
-using namespace std;
-
-void s(int i, int k, int n, char str[]);
-
-int main()
-{
- char ss[] = "SANTO";
- s(0, 4, sizeof(ss), ss);
-
- return 0;
-}
-
-void s(int i, int k, int n, char str[])
-{
- if(i < n - k){
- if(i < n-k) for(int j = i; j < i+k; j++) cout << str[j];
- cout << "\n";
- s(i+=1, k, n, str);
- }
-}