|
发表于 2022-5-18 11:35:23
|
显示全部楼层
本帖最后由 jhq999 于 2022-5-18 11:39 编辑
- struct JUBO
- {
- int id;
- int count;
- int *clude;
- struct JUBO* next;
- };
- int main(void)
- {
- int n=0,count=0,id=0,clude=0;
- scanf("%d",&n);
- struct JUBO head[1]={0},*p=NULL;
- for (int i = 0; i < n; i++)
- {
- scanf("%d%d",&id,&count);
- for (int j = 0; j < count; j++)
- {
- scanf("%d",&clude);
- p=head->next;
- while (p)
- {
- if (p->id==clude)
- {
-
-
- p->clude[(p->count)++]=id;
-
- if (p->count>head->next->count)
- {
- struct JUBO tmp=*p;
- p->id=head->next->id;
- p->count=head->next->count;
- p->clude=head->next->clude;
- head->next->id=tmp.id;
- head->next->count=tmp.count;
- head->next->clude=tmp.clude;
- }
- break;
- }
- p=p->next;
- }
- if(NULL==p)
- {
- p=new JUBO;
- p->id=clude;
- p->count=1;
- p->clude=new int[n];
- p->clude[0]=id;
- p->next=head->next;
- head->next=p;
- }
- }
- }
- p=head->next;
- printf("%d\n",p->id);
- for (int i = 0; i < p->count; i++)
- {
- for (int j = i+1; j < p->count; j++)
- {
- if (p->clude[i]>p->clude[j])
- {
- int t=p->clude[i];
- p->clude[i]=p->clude[j];
- p->clude[j]=t;
- }
- }
- printf("%d ",p->clude[i]);
- }
- while (p)
- {
- delete[] p->clude;
- head->next=p->next;
- delete p;
- p=head->next;;
- }
- return 0;
-
- }
复制代码 |
|