Home > Back-end >  For years, to help
For years, to help

Time:09-17

Known a company design department personnel shown in the table below, please choose a kind of storage structure will be stored, and choose a sorting algorithm, in accordance with the working status as a keyword for sorting,
Gonghaowu gender name
The king of 23 male fire
12 male YiFeng
45 female xiao-hua zhang
18 men li chao
18 female than thought,
77 female Wu Fang
4 male Liu Yiming
96 male Deng Wei
Bosses like to use the problem is data structure index table or link table, but I don't know what to write, help bosses thanks

CodePudding user response:

With your property, it is good to the array, did not say must be linked list

CodePudding user response:

With a structure array can
Typedef struct staff {//define structure
Int id;
Char gender [8].
Char name [20].
} the STA.

The STA stas []={//define an array
{23, "male", "king fire"},
{12, "male", "YiFeng"},
.
{96, "male", "Deng Wei"}
};

CodePudding user response:

reference 1/f, Simple, Soft reply:
with your property, the array is good, did not say must list

Thank you,,

CodePudding user response:

refer to the second floor qybao response:
with a structure array can
Typedef struct staff {//define structure
Int id;
Char gender [8].
Char name [20].
} the STA.

The STA stas []={//define an array
{23, "male", "king fire"},
{12, "male", "YiFeng"},
.
{96, "male", "Deng Wei"}
};

Thank you very much bosses

CodePudding user response:

refer to the second floor qybao response:
with a structure array can
Typedef struct staff {//define structure
Int id;
Char gender [8].
Char name [20].
} the STA.

The STA stas []={//define an array
{23, "male", "king fire"},
{12, "male", "YiFeng"},
.
{96, "male", "Deng Wei"}
};

Bosses if need to use the digital comparison order do?

CodePudding user response:

refer to the fifth floor I don 't know reply:
Quote: refer to the second floor qybao response:
with a structure array can
Typedef struct staff {//define structure
Int id;
Char gender [8].
Char name [20].
} the STA.

The STA stas []={//define an array
{23, "male", "king fire"},
{12, "male", "YiFeng"},
.
{96, "male", "Deng Wei"}
};

Bosses if need to use the digital comparison order do?



Define a temporary structure, and then use student id sorting
The STA temp.
Then the circulation order
If (stas [I] id & lt; Stas [I + 1])
{
Temp=stas [I];
Stas [I]=stas [I + 1);
Stas [I + 1)=temp;
}

CodePudding user response:

refer to 6th floor CHXCHXKKK response:
Quote: refer to the fifth floor I don 't know reply:

Quote: refer to the second floor qybao response:
with a structure array can
Typedef struct staff {//define structure
Int id;
Char gender [8].
Char name [20].
} the STA.

The STA stas []={//define an array
{23, "male", "king fire"},
{12, "male", "YiFeng"},
.
{96, "male", "Deng Wei"}
};

Bosses if need to use the digital comparison order do?



Define a temporary structure, and then use student id sorting
The STA temp.
Then the circulation order
If (stas [I] id & lt; Stas [I + 1])
{
Temp=stas [I];
Stas [I]=stas [I + 1);
Stas [I + 1)=temp;
}

Bosses I have a question, they there is a string, does not affect the comparison, thank you

CodePudding user response:

Does not affect, conform to the conditions of direct exchange structure

CodePudding user response:

refer to the eighth floor CHXCHXKKK response:
does not affect, conform to the conditions of direct exchange structure

Okk thanks bosses

CodePudding user response:

refer to the eighth floor CHXCHXKKK response:
does not affect, conform to the conditions of direct exchange structure

#include
#include
#include
Typedef struct staff {//define structure
Int id;
Char gender [8].
Char name [20].
} the STA.
The STA stas []={//define an array
{23, "male", "king fire"},
{12, "male", "YiFeng"},
{45, "female", "xiao-hua zhang"},
{18, "male", "li chao"},
{18, "female", "thinking,"},
{77, the "female", "Wu Fang"},
{4, "male", "Liu Yiming"},
{96, "male", "Deng Wei"}
};

Int main () {
The STA temp.
int i;
for(i=0; i<=7. I++)
{
If (stas [I] id> Stas [I + 1] id)
{
Temp=stas [I];
Stas [I]=stas [I + 1);
Stas [I + 1)=temp;
}
Printf (" % c \ n ", stas [I]);
} return 0;
}
Bosses I this code wrong he only output the digital output

CodePudding user response:

Your code changes and reference
 
#include
#include
#include

//define structure
Typedef struct staff
{
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related