Just started out on codeforces a few days ago. My solution code (in C++) to question 71A https://codeforces.com/problemset/problem/71/A isn't compiling on their server and I haven't got a clue. Need help - What have I done wrong and what can I do to fix this? The solution code that I'd submitted -
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
string a[n];
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
for (int i = 0; i < n; i++)
{
if (a[i].length() > 10)
{
cout << a[i][0] << a[i].length() - 2 << a[i][a[i].length() - 1] << endl;
}
else
{
cout << a[i] << endl;
}
}
return 0;
}
This was working just fine on my local compiler, but threw errors on their server -
Cannot compile file:
program.cpp
program.cpp(7) : error C2057: expected constant expression
program.cpp(7) : error C2466: cannot allocate an array of constant size 0
program.cpp(7) : error C2133: 'a' : unknown size
program.cpp(9) : error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::istream' (or there is no acceptable conversion)