Guest User

Untitled

a guest
Apr 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. static class FusionInterClassement
  5. {
  6.  
  7.  
  8. public static Queue<int> Fusion(Queue<int> f1, Queue<int> f2)
  9. {
  10. int i;
  11. Queue<int> f = new Queue<int>();
  12.  
  13. while(f1.Count == 0 || f2.Count == 0)
  14. {
  15. if (f1.Count == 0)
  16. {
  17. f.Enqueue(f2.Peek());
  18. f2.Dequeue();
  19. }
  20. else if(f2.Count == 0)
  21. {
  22. f.Enqueue(f1.Peek());
  23. f1.Dequeue();
  24. }
  25. else
  26. {
  27. if(f1.Peek() > f2.Peek())
  28. {
  29. f.Enqueue(f2.Peek());
  30. f2.Dequeue();
  31. }
  32. else
  33. {
  34. f.Enqueue(f1.Peek());
  35. f1.Dequeue();
  36. }
  37. }
  38. }
  39. return f;
  40. }
  41.  
  42. static void Main()
  43. {
  44. int v1, v2;
  45. int n;
  46. Queue<int> f1;
  47.  
  48. Console.Write("Combien de valeurs contient la première file ?");
  49. v1 = int.Parse(Console.ReadLine());
  50. for(f1 = new Queue<int>() ; f1.Count <= v1 ; i++)
  51. {
  52. Console.Write("Valeur ?");
  53. n = int.Parse(Console.ReadLIne());
  54. f1.Enqueue(n);
  55. }
Add Comment
Please, Sign In to add comment