views:

66

answers:

1

I solved the problem (Hoppity) as given on Facebook Puzzle Page. I solved it in c++ language (using g++ compiler) and mailed the .cpp file as an attachment to the mentioned e-mail address. I didn't zip the file. After few hours I received a mail regarding run/build error. Can anyone please help me with this. Where m I going wrong?

Here's the code I submitted:

#include<iostream>
#include<fstream>
using namespace std;
int main()
{
    long long i,n,k;
    ifstream fin("a.in");
    ofstream fout("output.in");
    fin>>n;
    k=n/15;
    for(i=0;i<k;i++)
    {
        fout<<"Hoppity"<<"\n";
        fout<<"Hophop"<<"\n";
        fout<<"Hoppity"<<"\n";
        fout<<"Hoppity"<<"\n";
        fout<<"Hophop"<<"\n";
        fout<<"Hoppity"<<"\n";
        fout<<"Hop"<<"\n";
    }
    for(i=k*15+1;i<=n;i++)
    {
        if(i%5==0) fout<<"Hophop"<<"\n";
        else if(i%3==0) fout<<"Hoppity"<<"\n";
    }
    return 0;
}
+2  A: 

What strikes me is that you do not take the name of your input file from the command line like the Hoppity puzzle demands. Instead, you read input from some "a.in" file.

Furthermore, you're expected to write the results to STDOUT, not some "output.in" file.

ig2r