请...我需要解决这个问题 [英] please... I need to solve this proqrame
本文介绍了请...我需要解决这个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我...
删除队列中的中值节点
Help me... please :
delete median node(s) in queue
推荐答案
嗨 我有一个主意,但没有尝试过,它不会起作用.
1.从队列中收集数组中的值.
2.使用任何排序对其进行排序.
3.找到中间值.
4.int NoToRemove =中间值.
5.queue.Remove(NoToRemove).
Hi i hav an idea but didnt try will it work r not.
1.Collect the values in array from queue.
2.Sort them using any sort.
3.Find the middle value.
4.int NoToRemove = middlevalue.
5.queue.Remove(NoToRemove).
class Program
{
static void Main()
{
// New Queue of integers.
Queue<int> queue = new Queue<int>();
queue.Enqueue(5);
queue.Enqueue(10);
queue.Enqueue(15);
queue.Enqueue(20);
// Create new array with Length equal to Queue's element count.
int[] array = new int[queue.Count];
// Copy the Queue to the int array.
queue.CopyTo(array, 0);
//sort the array and find the middle value
int textToRemove = middlevalue;
queue.Remove(texttoRemove);
}
}
我认为这可以....
i think this will work....
这篇关于请...我需要解决这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文