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> #define MAX 100 using namespace std; int main() { int n; cin>>n; int i,sum=0; int temp; int s[MAX]; for(i=2;i<MAX;i++) { sum+=i; if(sum>n) { temp=i-1; sum-=i; break; } } for(i=0;i<temp-1;i++) { s[i]=2+i; } for(i=temp-2;i>=0;i--) { if(sum!=n) { sum++; s[i]++; } else break; } for(i=0;i<temp-1;i++) { cout<<s[i]<<' '; } 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