| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
看看还能比这个简单么? 我瞎蒙的....#include <iostream.h>
int main(int argc, char *argv[])
{
int n=7,i,t;
cin>>n;
for(i=2;n>=i;i++) n-=i;
i--;//原来多加了一个1
if(i==n)
{
for(t=2;t<=i-1;t++)
{
cout<<t+1<<" ";
}
cout<<i+2<<" ";
}
else
{
for(t=2;t<=i;t++)
{
if(i-t<n) cout<<t+1<<" ";
else cout<<t<<" ";
}
}
cout<<endl;
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator