Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- static class FusionInterClassement
- {
- public static Queue<int> Fusion(Queue<int> f1, Queue<int> f2)
- {
- int i;
- Queue<int> f = new Queue<int>();
- while(f1.Count == 0 || f2.Count == 0)
- {
- if (f1.Count == 0)
- {
- f.Enqueue(f2.Peek());
- f2.Dequeue();
- }
- else if(f2.Count == 0)
- {
- f.Enqueue(f1.Peek());
- f1.Dequeue();
- }
- else
- {
- if(f1.Peek() > f2.Peek())
- {
- f.Enqueue(f2.Peek());
- f2.Dequeue();
- }
- else
- {
- f.Enqueue(f1.Peek());
- f1.Dequeue();
- }
- }
- }
- return f;
- }
- static void Main()
- {
- int v1, v2;
- int n;
- Queue<int> f1;
- Console.Write("Combien de valeurs contient la première file ?");
- v1 = int.Parse(Console.ReadLine());
- for(f1 = new Queue<int>() ; f1.Count <= v1 ; i++)
- {
- Console.Write("Valeur ?");
- n = int.Parse(Console.ReadLIne());
- f1.Enqueue(n);
- }
Add Comment
Please, Sign In to add comment