vencinachev

Queue N N+1 2N+1

Oct 19th, 2020
1,700
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3.                    
  4. public class Program
  5. {
  6.     public static void Main()
  7.     {
  8.         Queue<int> q = new Queue<int>();
  9.         int n = 3;
  10.         int count = int.Parse(Console.ReadLine());
  11.         q.Enqueue(n);
  12.         for (int i = 0; i < count; i++)
  13.         {
  14.             int num = q.Dequeue();
  15.             Console.Write("{0} ", num);
  16.             q.Enqueue(num + 1);
  17.             q.Enqueue(2 * num + 1);
  18.             q.Enqueue();
  19.         }
  20.     }
  21. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×