From 483d63fa7249ad8d6020680c48c3cf6df35010b3 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 26 Apr 2017 16:37:39 +0200 Subject: Moved all C++ files into CPP folder --- scommesse.cpp | 81 ----------------------------------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 scommesse.cpp (limited to 'scommesse.cpp') diff --git a/scommesse.cpp b/scommesse.cpp deleted file mode 100644 index 2fa0936..0000000 --- a/scommesse.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* INPUT: - * 11 - * 1 0 2 6 4 5 3 9 8 10 7 - * - * OUTPUT: - * 2 - * 8 2 - */ -#include -#include -#include -#include - -using namespace std; - -vector carteOut; - -void cOutPresente(vector& kr, int x) -{ - bool s = false; - for(unsigned i = 0; i < kr.size(); i++) - if(kr[i] == x) s = true; - - if(!s) - kr.push_back(x); -} - -void fCarte(vector c, int N, int s) -{ - int i; - vector::iterator it; - vector::iterator start; - - while(c.size() > 1) { - //for(it = c.begin(); it != c.end(); it++) cout << *it << ' '; cout << endl; - int tot = c.size(); - for(i = s; i < tot-1; i++) { - if(!(((c[i] + c[i+1]) % 2) == 0)) { - start = c.begin()+i; - c.erase(start, start+2); - break; - } - } - - s = 0; - } - cOutPresente(carteOut, c[0]); -} - -int main() -{ - ifstream in("input.txt"); - ofstream out("output.txt"); - int N, i; - in >> N; - - int x; - vector carteV; - - for(i = 0; i < N; i++) { - in >> x; - carteV.push_back(x); - } - - for(int i = 0; i < N; i++) { - fCarte(carteV, N, i); - } - - reverse(carteV.begin(), carteV.end()); - - for(int i = 0; i < N; i++) { - fCarte(carteV, N, i); - } - - out << carteOut.size() << endl; - for(vector::iterator ite = carteOut.begin(); ite != carteOut.end(); ite++) out << *ite << ' '; - - out.close(); - in.close(); - return 0; -} -- cgit v1.2.3-18-g5258