您的位置:首页 > 其它

uvaoj 488 - Triangle Wave

2011-08-01 15:26 260 查看
#define LOCAL
#include<iostream>
using namespace std;
void print(int n)
{
int i,j;
for(i=1;i<n;i++)
{
for(j=0;j<i;j++)
cout<<i;
cout<<endl;
}
for(i=n;i>=1;i--)
{
for(j=0;j<i;j++)
cout<<i;
cout<<endl;
}
}
int main()
{
#ifdef LOCAL
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

int n,x,y,first=1;
cin>>n;
while(n--)
{
if(!first)
{cout<<endl;}
else
first=0;
cin.get();           //我以为x,y都是整型cin就会跳过空格,看来我错了。。。
cin>>x>>y;
print(x);
y--;
while(y--)
{
cout<<endl;
print(x);
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: