本文共 830 字,大约阅读时间需要 2 分钟。
#include#include #include #include #define N 1010using namespace std;struct node{ double avg; int si,v,fa; bool exist;}nodes[N];int find_fa(int x){ int fa = nodes[x].fa; while(!nodes[fa].exist){ fa = nodes[fa].fa; } return fa;}int find_max(int r,int n){ int res; double mx = -1; for(int i=1;i<=n;i++){ if(i!=r&&nodes[i].exist&&nodes[i].avg>mx){ mx = nodes[i].avg; res = i; } } return res;}int main(){ struct node no; int n,r; scanf("%d %d",&n,&r); while(n!=0&&r!=0){ for(int i=1;i<=n;i++){ scanf("%d",&nodes[i].v); nodes[i].si = 1; nodes[i].avg = nodes[i].v; nodes[i].exist = true; } for(int i=1;i
转载地址:http://xllzi.baihongyu.com/