您的位置:首页 > 其它

ACM JOJ 1007

2015-12-18 18:05 369 查看
#include <iostream>

using namespace std;

int main()

{

int
number,n=2000;

int
flag=0,local;


while(cin>>number)

{


flag=0;


if(number==0)


break;


else if(number==1)


{


cout<<number<<"
is a triangular number."<<endl;


cout<<"*"<<endl;


}


else


{


for(int i=2;i<2000;i++)


{


if(number==(1+i)*i/2)


{


flag=1;


local=i;


break;


}


}


if(flag)


{


cout<<number<<"
is a triangular number."<<endl;


for(int j=1;j<=local;j++)


cout<<string(j,'*')<<endl;


}


else


cout<<number<<"
is not a triangular
number."<<endl;


}

}

return
0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: