【发布时间】:2014-03-05 16:35:48
【问题描述】:
我已经嵌套为:
typedef struct a{
const char * LongName;
const char * ShortName;
int a;
struct a * next;
}Level5;
typedef struct a1{
const char * LongName;
const char * ShortName;
int frequency5;
int id;
Level5 * linked;
struct a1* next_a1;
}Level4;
typedef struct a2{
const char * Name;
int frequency4;
Level4 * linked;
int id;
struct a2 * next;
}Level3;
typedef struct a3{
const char * LongName;
const char * ShortName;
int frequency3
int id;
Level3 * linked;
}Level2;
typedef struct a4{
const char * LongName;
const char * ShortName;
_Bool top;
int id;
int frequency2;
Level2 * lined;
}Level1;
typedef struct cat{
int id;
const char * CatName;
Level1 * linked;
}CAT;
CAT total[256];
现在我想将链接的嵌套结构结构排序如下:
1. Level 5 -> LongName
2. Level 4 -> ShortName
3. Level 3 -> Name
4. Level 2 -> Frequency3
Level 1
|
| Level 2
====================================================
| Level3 |Level3 |level 3
=============
| next next
level4 -> lev4 -> lev4
| |
| =====================================
=============================== |
| next next Level5 -> level5 -> level5
Level5 -> Level5 -> level5
【问题讨论】:
-
需要澄清一下:所有项目都是先按级别排序,然后按专业排序吗?
-
是否所有 5 级项目都按
LongName排序,即使它们共享公共字段? -
@ThomasMatthews 第一个问题的答案是肯定的,这就是我要找的。 LongName 在每个结构中都不同。对于安装 level5 abc 然后 level4 def level3 ghi level2 jkl level1 xzy。名称可能相同,但每个结构中的值不同
标签: c++ c xcode visual-c++ gcc