提交时间:2023-09-12 13:34:57

运行 ID: 102133

#include<iostream> using namespace std; int a[1005]; int main(){ int b,c,Bi=0; bool t=0; cin>>b; for(int i=1;i<=b;i++){ cin>>c; a[c]++; } for(int i=1;i<=b-1;i++){ Bi=0; for(int p=1;p<=b;p++){ if(a[Bi]<a[p]){ Bi=p; } } if(Bi!=0){ if(t==1){ cout<<"->"<<Bi; }else{ cout<<Bi; t=1; } } a[Bi]=0; } }