Sign in
Log inSign up

Is my code clean enough?

Đăng Tú's photo
Đăng Tú
·Sep 20, 2018

I'm practicing writing C++ on HackerRank and try makin' a good, clean code. So, is my code clean enough?

#include <iostream>
#include <cstdio>
using namespace std;

string number [9]
{
    "one",
    "two",
    "three",
    "four",
    "five",
    "six",
    "seven",
    "eight",
    "nine"
};

int minN, maxN;

void checkN(int);


int main()
{
    cin >> minN >> maxN;
    for (int i = minN; i <= maxN; i++)
    {
        checkN(i);
    }

    return 0;
}


void checkN(int n)
{
    if (n >= 1 && n <=9)
        cout << number[n - 1] << endl;
    else if (n > 9)
        cout << ((n % 2 == 1) ? "odd" : "even") << endl;

}

If my code is clean, could you tell me what part is clean, vice versa for not-very-clean. Thanks in advance.