shell renice 改變系統上已執行命令的優先順序
阿新 • • 發佈:2020-11-30
intmax_num(int*num_of_character,intsize);
char*reorganizeString(char*S)
{
intnum_of_character[26]={0};
intlen=strlen(S);
inttemp_max=0;
inttemp_num=0;
char*tem_s=(char*)malloc(sizeof(char)*(len+1));
tem_s[len]=0;
for(inti=0;i<len;i++)
{
num_of_character[S[i]-'a']++;
}
intlimit=(len+1)/2;
temp_max=max_num(num_of_character,26);
while(num_of_character[temp_max]!=0)
{
if(num_of_character[temp_max]>limit)
return"";
for(inti=0;i<num_of_character[temp_max];i++)
{
tem_s[temp_num]=temp_max+'a';
temp_num+=2;
if(temp_num>len-1)
{
temp_num=1;
}
}
num_of_character[temp_max]=0;
temp_max=max_num(num_of_character,26);
}
returntem_s;
}
intmax_num(int*num_of_character,intsize) { intn=0; for(inti=1;i<size;i++) { if(num_of_character[n]<num_of_character[i]) n=i; } returnn; }
intmax_num(int*num_of_character,intsize) { intn=0; for(inti=1;i<size;i++) { if(num_of_character[n]<num_of_character[i]) n=i; } returnn; }
test