标签:sort ota algorithm 题记 for class cin 结果 break
这道题放在紫书最后一道,我以为挺难的,没想到挺简单的。
怎么一直不给结果,不等了,先睡了,明天再起来看。
#include<cstdio> #include<iostream> #include<algorithm> using namespace std; int main(){ int m,n,kase=0; double total; while(scanf("%d%d",&m,&n)==2&&m!=0){ printf("Region %d\n",++kase); int region[m*n]; for(int i=0;i<m*n;i++)scanf("%d",®ion[i]); cin>>total; int t=total/100.0; sort(region,region+m*n); int i,j; for(i=0;i<m*n;i++){ for(j=0;j<i;j++)total+=region[j]; total=total/i; if(region[i]>total)break; total=t; } printf("Water level is %.2f meters.\n",total); printf("%.2f percent of the region is under water.\n\n",i/(double)(m*n)*100); } return 0; }
标签:sort ota algorithm 题记 for class cin 结果 break
原文地址:https://www.cnblogs.com/hardworkingshow/p/12302001.html