11074 - Draw Grid

Moderator: Board moderators

New poster
Posts: 5
Joined: Sun Aug 23, 2009 7:26 am

11074 - Draw Grid

would some one tell me why am getting WA

Code: Select all

``````#include <iostream>

using namespace std;

int main()
{
int S , T , N ;

for ( int counter = 1 ; ; counter++ )
{

cin >> S >> T >> N ;

if ( T == 0 && S == 0 && N == 0 )
break ;

cout << "Case " << counter << ":" << endl ;

for ( int i = 0 ; i < T + 1 ; i++ )
{
for ( int j = 0 ; j < T ; j++ )
{
for ( int k = 0 ; k < ( S * N ) + ( N + 1 ) *  T ; k++ )
cout << '*';
cout << endl ;
}
if ( i == T )
break;
for ( int i = 0 ; i < S  ; i++ )
{
for ( int y = 0 ; y < N + 1 ; y++ )
{
for ( int a = 0 ; a < T ; a++ )
cout << '*' ;
if ( y == N )
break;
for ( int k = 0; k < S ; k++ )
cout << '.';
}
cout << endl;
}

}
}
return 0;
}

``````
please guys help me out it

ChopinPlover
New poster
Posts: 1
Joined: Thu Jul 11, 2013 8:21 am

Re: 11074 - Draw Grid

Check the case: 4 1 5

unreleased
New poster
Posts: 16
Joined: Sun Nov 10, 2013 7:41 pm

Re: 11074 - Draw Grid

why WA??

Code: Select all

``````#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <map>
#include <set>
#include <sstream>
#include <utility>
#include <bitset>

#define mx 1000000
#define INT 2147483647

#define D   double
#define L   long
#define LL  long long
#define ULL unsigned long long

#define isc1(a)      scanf("%d", &a)
#define isc2(a,b)    scanf("%d%d", &a, &b)
#define isc3(a,b,c)  scanf("%d%d%d", &a, &b, &c)
#define llsc1(a)     scanf("%I64d", &a)
#define llsc2(a,b)   scanf("%I64d%I64d", &a, &b)
#define llsc3(a,b,c) scanf("%I64d %I64d %I64d", &a,&b,&c)

#define f(a,n)  for(a=0; a<n; a++)
#define all(a)  a.begin(), a.end()
#define ms(arr) memset(arr, 0, sizeof(arr))
#define cl(a)   a.clear()
#define sz(a)   a.size()

#define sc scanf
#define pf printf
#define pu push_back
#define pb pop_back
#define vc vector
#define mp make_pair
#define fi first
#define se second
#define pip pf("pip.....\n")

using namespace std;

int main()
{
//    freopen("input.txt", "r", stdin);
//    clock_t start = clock();
int a,b,c=1,d;
string str, str1, str2;
int s,t,n, len;
while(isc3(s, t, n)==3)
{
cl(str); cl(str2); cl(str1);
if(s+t+n==0)break;
if(c>1)pf("\n");
pf("Case %d:\n", c++);

len=(s+t)*n + t;

for(a=1; a<=len; a++)str1+='*';

for(a=1; a<=s+t; a++)
{
if(a<=t)str2+='*';
else str2+='.';
}
for(a=1; a<=n; a++)str+=str2;
for(a=1; a<=t; a++)str+='*';

for(a=1; a<=len; )
{
for(b=1; b<=t && a<=len; b++)
{
cout<<str1<<endl;
a++;
}

for(d=1; d<=s && a<=len; d++)
{
cout<<str<<endl;
a++;
}
}
}

//    start = clock()-start;
//    pf("\n%lf sec", start/(D)CLOCKS_PER_SEC);

return 0;
}
``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11074 - Draw Grid

Print a blank line after the output of each case, including the last one.
Check input and AC output for thousands of problems on uDebug!

unreleased
New poster
Posts: 16
Joined: Sun Nov 10, 2013 7:41 pm

Re: 11074 - Draw Grid

brianfry713 wrote:Print a blank line after the output of each case, including the last one.
aaah AC