summaryrefslogtreecommitdiff
path: root/Year_1/Programming_2/exercises/even-length.cc
blob: 2d3d6a44e1c1453b7337b73701cce4d53c3524b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<iostream>
#include<string>
#include<fstream>

using namespace std;

string result(string s) {
    if(s.length() % 2 == 0)
        return s;

    return s.substr(0, s.length()-1);
}

int main() {
    ifstream in("input.txt");
    ofstream out("output.txt");

    for(int ts = 0; ts < 100; ++ts) {
        string s;
        in >> s;
        out << result(s) << '\n';
    }

    in.close();
    out.close();
    return 0;
}