#include<iostream>
using namespace std;
int main( int argc, char * argv[] )
{ int use[10]={0,1,22,333,4444,55555,666666,7777777,88888888,999999999};
long i , j , k ,l;
long n , a , f ;
cin >> n ;
for(i=0;i<n;i++) {
cin >> a >> f;
for(j=0;j<f;j++) {
for(k=1;k<=a;k++) cout << use[k] << endl;
for(k=a-1;k>=1;k--) cout << use[k] << endl;
cout << endl;
}
}
return 0;
}
That output looks good to me. The only thing tricky about this problem is making sure not to print an empty line at for the very last triangle wave, and being able to print all of the triangle waves fast enough.
helloneo wrote:You're printing an extra blank line at the first line..
But the question says "This line is followed by a blank line, and there is also a blank line between two consecutive inputs", so shouldn't there be a blank line after the first line ??
I did try to remove it but still got a WA...Anyway, thanks for your help !
Don't know where I'm doing wrong. I've tried several things and changed it around a lot, but I keep getting a wrong answer. I checked my output with every thread containing 488, but each and every time, I can't figure out what is going on.
Why i got TLE..It's really strange..And i changed using scanf() and printf (),it becamed WA..And i want to know what is blue flag,and what is the meaning of so called multiple input.It isn't like the input about this problem?Thanks in advance~
#include <iostream.h>
int main ()
{
int i, j, k;
int caseNum;
int a, f;
char num[10][10] = {"", "1", "22", "333", "4444", "55555", "666666", "7777777", "88888888", "999999999"};
cin>>caseNum;
for (i = 0; i < caseNum; i++)
{
cin>>a>>f;
for (j = 0; j < f; j++)
{
for (k = 1; k <= a; k++)
{
cout<<num[k]<<endl;
}
k = k - 2;
for (; k >= 1; k--)
{
cout<<num[k]<<endl;
}
cout<<endl;
}
}
return 0;
}