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 |
为什么我这个代码C++能过G++不能?#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<fstream> using namespace std; #define LEN 1000 //#define cin fin //ifstream cin("1.txt"); int main (void) { int n,m,start,maxn,num,sum,i; int region[LEN]; double water,remain; num=1; while(cin>>n>>m&&(n||m)){ for(i=0;i<n*m;i++) cin>>region[i]; cin>>maxn; sort(region,region+n*m); start=region[0]; sum=0; for(i=1;i<n*m;i++) if(sum+(region[i]-start)*i*100<=maxn){ sum+=(region[i]-start)*i*100; start=region[i]; } else break; remain=maxn-sum; water=region[i-1]+remain/(double(i)*100.0); for(i=0;region[i]<water&&i<n*m;i++); printf("Region %d\n",num++); printf("Water level is %.2f meters.\n",water); printf("%.2f percent of the region is under water.\n\n",100*i/double(n*m)); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator