1 // 2008 ACM Mid-Central USA Regional Programming Contest 2 // Solution to Problem A: "Parity" [very easy] 3 // Eric Shade, Missouri State University 4 5 #include <iostream> 6 #include <fstream> 7 using namespace std; 8 9 int main() { 10 ifstream in("parity.in"); 11 int p = 0; 12 char c; 13 14 while ((c = in.get()) != '#') { 15 switch (c) { 16 case '0': cout << c; break; 17 case '1': cout << c; p = 1 - p; break; 18 case 'e': cout << p << endl; p = 0; break; 19 case 'o': cout << (1 - p) << endl; p = 0; 20 // note that newlines in the input are read and ignored 21 } 22 } 23 24 in.close(); 25 }