Tianjin University Online Judge
Contests Virtual Contests Problems Submit Runs Status Rank List Forum


PE , HELP! -- Problem 2967

ghooghooli 6136. PE , HELP!
2008-06-04 01:50:58 i got PE bau i can't find why.
could anybody helps?
Thanks

#include <iostream>

using namespace std;

void Trig();
void Rect();
void Pal();

int main()
{

    int C;
    while(cin>>C)
    {
        if(C<0)
            break;
        switch(C)
        {
        case 1:
            Trig();
            break;
        case 2:
            Pal();
            break;
        case 3:
            Rect();
            break;
        };

    }

    return 0;
}

void Trig()
{
    int H;
    cin>>H;
    int index=H-1;
    for(int i=1;i<=H;i++)
    {
        for(int j=0;j<index;j++)
            cout<<" ";
        for(int j=0;j<(i*2)/2-1;j++)
            cout<<"*";
        cout<<"*";
        for(int j=0;j<(i*2)/2-1;j++)
            cout<<"*";
        cout<<endl;
        index--;
    }
    cout<<endl;
}

void Rect()
{
    int W,H;
    cin>>W>>H;
    for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
            cout<<"*";
        cout<<endl;
    }
    cout<<endl;
}

void Pal()
{
    int W,H,index;
    cin>>W>>H;
    if(W>=H)
    {
        index=H-1;
        for(int i=0;i<H;i++)
        {
            for(int j=0;j<index;j++)
                cout<<" ";
            index--;
            for(int j=0;j<W;j++)
                cout<<"*";
            cout<<endl;
        }
        cout<<endl;
    }
    else
    {
        index=0;
        for(int i=0;i<H;i++)
        {
            for(int j=0;j<index;j++)
                cout<<" ";
            for(int j=0;j<W;j++)
                cout<<"*";
           
            index++;
            cout<<endl;
        }
        cout<<endl;
    }

}
kk 6431. Re:PE , HELP!
2008-10-03 21:56:03 i got the same problem!!!!
DotaAllways 6542. Re:PE , HELP!
2008-11-18 16:35:22 me too, i saw there are always two blank lines although i use one cout<<endl;
  1

Search    Goto Page:  
User ID:
Password:
Title:

Tianjin University Online Judge v1.2.4