本来这应该是一道很简单的题的,但是题目对空格的要求很高,所以我WA了好几次。而且读入数据的时候我

居然加了getchar();...这也是WA的罪魁祸首!

贴代码:

#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
int n, a, f;
cin >> n;
int cas = 0;
while( n --)
{
if( cas ++) printf("\n");
cin >> a >> f;
while( f -- )
{
for(int i = 1; i <= a; i ++)
{
for( int j = 0; j < i; j ++)
cout << i;
cout << endl;
}

for(int i = a-1; i >= 1; i --)
{
for( int j = 0; j < i; j ++)
cout << i;
cout << endl;
}
if( f > 0) cout << endl;
}
}
return 0;
}

 

相关文章:

  • 2021-07-03
  • 2021-10-01
  • 2021-12-27
  • 2021-07-21
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-13
  • 2021-10-04
  • 2021-10-31
  • 2021-09-20
  • 2021-05-23
  • 2021-11-09
相关资源
相似解决方案