Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace CalculateSequenceWithQueue
- {
- class Program
- {
- static void Main(string[] args)
- {
- Queue<int> seqTemp = new Queue<int>();
- Queue<int> seqPrint = new Queue<int>();
- int N = int.Parse(Console.ReadLine());
- seqTemp.Enqueue(N);
- while(seqPrint.Count<=49)
- {
- seqTemp.Enqueue(seqTemp.Peek() + 1);
- seqTemp.Enqueue(2*seqTemp.Peek() + 1);
- seqTemp.Enqueue(seqTemp.Peek() + 2);
- seqPrint.Enqueue(seqTemp.Dequeue());
- }
- while (seqPrint.Count > 0)
- {
- Console.Write(seqPrint.Dequeue()+" ");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement