using
System;
using
System.Collections.Generic;
using
System.Linq;
public
class
GFG{
static
List<
string
> Tokenizer(
string
str)
{
List<
string
> list =
new
List<
string
>();
string
temp =
""
;
for
(
int
i = 0; i < str.Length; i++) {
if
(str[i] ==
' '
) {
list.Add(temp);
temp =
""
;
}
else
{
temp += str[i];
}
}
list.Add(temp);
return
list;
}
static
string
SortListByOddIndices(List<
string
> list,
int
x)
{
int
l = list.Count;
for
(
int
i = l - 1; i > 0; i -= 2) {
if
(Int32.Parse(list[i]) < x) {
list.RemoveRange(i - 1, 2);
}
}
l = list.Count;
for
(
int
i = 1; i < l; i += 2) {
for
(
int
j = 1; j < l - i; j += 2) {
if
(list[j] == list[j + 2]) {
if
(list[j - 1].Length > list[j + 1].Length) {
string
temp1 = list[j];
string
temp2 = list[j - 1];
list[j] = list[j + 2];
list[j - 1] = list[j + 1];
list[j + 2] = temp1;
list[j + 1] = temp2;
}
}
else
if
(list[j].Length < list[j + 2].Length) {
string
temp1 = list[j];
string
temp2 = list[j - 1];
list[j] = list[j + 2];
list[j - 1] = list[j + 1];
list[j + 2] = temp1;
list[j + 1] = temp2;
}
}
}
string
sortedList =
string
.Join(
" "
, list);
return
sortedList;
}
static
public
void
Main (){
string
str =
"Axc 78 Czy 60"
;
int
x = 77;
List<
string
> list = Tokenizer(str);
string
sortedList = SortListByOddIndices(list, x);
Console.WriteLine(sortedList);
Console.ReadLine();
}
}