Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

can't figure out why its wrong, pls help!

$
0
0

i tried to do this problem : http://www.codechef.com/problems/APGE02

and the thing is in my system m getting its answer but on posting my code here on codechef, it says output does not match like required, i think i have done it ryt but i cant figure out why is it not accepting...

please help me with this

here's the code : //dated : 28/11/2013 2228 hours

#include<fstream>
#include<iostream>

using namespace std;

int X;

void space(int x)
{
    for(int i=1;i<=x;i++)
        cout<<" ";
}


void star(int x)
{
    for(int i=1;i<=x;i++)
        cout<<".";

}

void f_e(int i)
{
    if(i==1)
    {
        space(2*(X-4));
    }
    else if(i==2)
        {
            space(X-6); star(1); 
            space(2);
            star(1); space(X-6);
        }
    else if(i==3)
        {
            space(X-7); star(6); space(X-7);
        }
    else
    {
        star(2*(X-4));
    }
}

void run_program()
{
    int s=0, v=0;

    for(int i=1;i<=X/2;i++)
    {
        space(s); 
        star((2*X)-v); 
        f_e(i); 
        star((2*X)-v); 
        cout<<"\n";

        s=s+2;; v=v+2;

    }

    v=0; s=X+(X-4);

    for(int i=1;i<=X/2;i++)
    {
        space(s); 
        star(2*(X-v));
        cout<<"\n";

        s=s+2;; v=v+2;
    }

    cout<<"***\n";

}

int main(int argc, char *argv[])
{

    ifstream fin(argv[1]);

    int N;

    fin>>N;

    for(int i=1;i<=N;i++)
    {
        fin>>X;
        run_program();
    }

    return 0;
}

Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>