Hello guys,i have some issues uploading a task 10152(shellsort) in the online judge website.
The code works fine,i get the results you need to get on my computer,but when i try to upload it on the site
it tells me that i have an error.
this is the code:

#include <iostream>
#include <vector>
#include <map>
#include <string>

using namespace std;

struct NameId
{
    string name;
    int id;
};

int main()
{
    freopen("input.txt", "r", stdin);

    int cases;
    cin >> cases;

    for (int i=0; i<cases; i++)
    {
        int n;
        cin >> n;
        cin.ignore();

        map<string, int> desiredMap;
        vector<NameId> original;
        vector<string> desiredVector;
        NameId nameId;
        string name;

        // Read the original order
        for (int j=0; j<n; j++)
        {
            getline(cin, name);
            nameId.id = 0; // we don't know the id yet, we need to read the desired order first
            nameId.name = name;
            original.push_back(nameId);
        }

        // Read the desired order
        for (int j=0; j<n; j++)
        {
            getline(cin, name);
            desiredMap[name] = j; // the first desired element will be 0, the 2nd 1 and so forth
            desiredVector.push_back(name); // just the same relationship but as vector so we can acess it via index
        }

        // Now write the correct id for the original order
        for (int j=0; j<n; j++)
        {
            original[j].id = desiredMap[original[j].name];
        }

        // A turtle is said to be in reverse if its number is less than the biggest number of the turtles above it in
        int biggest = -1, biggestReverse = -1;
        for (int j=0; j<n; j++)
        {
            if (original[j].id > biggest)
                biggest = original[j].id;
            else if (original[j].id > biggestReverse)
                biggestReverse = original[j].id;
        }

        // We just have to print the names now
        for (int j=biggestReverse; j>=0; j--)
        {
            cout << desiredVector[j] << endl;
        }

        cout << endl;
    }

    return 0;
}

And this is the input file that goes with it:

2
3
Yertle
Duke of Earl
Sir Lancelot
Duke of Earl
Yertle
Sir Lancelot
9
Yertle
Duke of Earl
Sir Lancelot
Elizabeth Windsor
Michael Eisner
Richard M. Nixon
Mr. Rogers
Ford Perfect
Mack
Yertle
Richard M. Nixon
Sir Lancelot
Duke of Earl
Elizabeth Windsor
Michael Eisner
Mr. Rogers
Ford Perfect
Mack

What error?? take your time and explain your problem very well. We need to understand what you want to achieve before we can assist you.

what kind of error? syntax or output?

what is the desired output?

well the code runs fine when i execute it on my computer,but i have to upload the code in the online judge.The problem is that when i uplode it the online judge compiler tells me that i have the folloing compilation erron:

code.cpp:1:1: error: expected unqualified-id before ‘[’ token
 [Project]
 ^

And it tells me that my problem is not solved
here is a link where i have to upload my solution
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1093

The submission specifications are very specific about not including any code that opens a file. Try submitting it without that.

Also are you sure that endl is only adding '\n' to the line? Try switching to that instead.

write c++ statment(s) that acomplish the following:
a.Declare int variables x and y. Initialize x to 25 and y to 18.
b.Declare and initialize an int variable temp to 1 and a char variable ch to 'A'
c.Update the value fof an int variable firstNum into an int varible tempNum.
d.Declare int variables to store four integers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.