From 89693f9e12bf76299a5cd50b55fce9dce6462a2a Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 18 May 2017 17:30:29 +0200 Subject: * --- cpp/parentesi.cpp | 58 -------------------------------------------- cpp/planet.cc | 72 ------------------------------------------------------- 2 files changed, 130 deletions(-) delete mode 100644 cpp/parentesi.cpp delete mode 100644 cpp/planet.cc (limited to 'cpp') diff --git a/cpp/parentesi.cpp b/cpp/parentesi.cpp deleted file mode 100644 index 159b75f..0000000 --- a/cpp/parentesi.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* INPUT: -[ ( ( [ { { [ ] ] ( ( ( } } ( ) ) ) ) ) ) ] ] ] - -output: -11 */ -#include -#include -#include - -using namespace std; - -int main() -{ - ifstream in; - ofstream out; - in.open("input.txt"); - out.open("output.txt"); - - int i; - int t = 0, q = 0, g = 0; //tonde, quadre, graffe - char str[1000], c; - i = 0; - while(!in.eof()) - { - in.get(c); - if(c == ' ') continue; - else { - str[i] = c; - i++; - } - } - - int n = strlen(str), tot = 0; - - for(int i = 0; i < n; i++) - { - if(str[i] == '(') t++; - else if(str[i] == '[') q++; - else if(str[i] == '{') g++; - - if(str[i] == ')' && t > 0) { - t--; - tot++; - } else if(str[i] == ']' && q > 0) { - q--; - tot++; - } else if(str[i] == '}' && g > 0) { - g--; - tot++; - } - } - - out << tot << endl; - - in.close(); - out.close(); - return 0; -} diff --git a/cpp/planet.cc b/cpp/planet.cc deleted file mode 100644 index 33cdea7..0000000 --- a/cpp/planet.cc +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include - -using namespace std; - -int main() -{ - ifstream in; - ofstream out; - in.open("input.txt"); - out.open("output.txt"); - - char ch; - string numero, val[2]; - int oraVuota = -1, giorno[96], i = 0, c = 0; - - for(int j = 0; j < 96; j++) giorno[j] = -1; - - getline(in, numero); - int N; - istringstream(numero) >> N; - - int ore[N][2]; - - while(!in.eof()) - { - in.get(ch); - - if(ch == '\n') { - val[0] = ""; - val[1] = ""; - i = 0; - c++; - - continue; - }else if(ch == ' '){ - i++; - }else { - val[i] += ch; - istringstream(val[i]) >> ore[c][i]; - } - - } - - i = 0; - while(i < N){ - if(ore[i][0] > ore[i][1]){ - for(int j = ore[i][0]; j < ore[i][1] || j < 96; j++) giorno[j] = 0; - for(int k = ore[i][1]-1; k >= 0; k--) giorno[k] = 0; - }else { - for(int k = ore[i][0]; k < ore[i][1]; k++) giorno[k] = 0; - } - i++; - } - - for(i = 0; i < 96; i++) { - if(giorno[i] == -1) { - oraVuota = i; - break; - } - - //cout << i << " " << giorno[i] << endl; - } - - out << oraVuota << endl; - - in.close(); - out.close(); - - return 0; -} -- cgit v1.2.3-18-g5258