Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SequenceQueue
- {
- public void Run()
- {
- int n = 2;
- Queue<int> frontMulplier = new Queue<int>();
- Queue<int> backAddin = new Queue<int>();
- frontMulplier.Enqueue(1);
- frontMulplier.Enqueue(2);
- frontMulplier.Enqueue(1);
- backAddin.Enqueue(1);
- backAddin.Enqueue(1);
- backAddin.Enqueue(2);
- Queue<int> mainQ = new Queue<int>();
- Queue<int> tempQ = new Queue<int>();
- tempQ.Enqueue(n);
- mainQ.Enqueue(n);
- for (int i = 0; i < 50; i++)
- {
- tempQ.Enqueue(frontMulplier.Peek() * tempQ.Peek() + backAddin.Peek());
- mainQ.Enqueue(frontMulplier.Peek() * tempQ.Peek() + backAddin.Peek());
- if (frontMulplier.Peek() == 1 && backAddin.Peek() == 2)
- {
- tempQ.Dequeue();
- }
- frontMulplier.Enqueue(frontMulplier.Peek());
- frontMulplier.Dequeue();
- backAddin.Enqueue(backAddin.Peek());
- backAddin.Dequeue();
- }
- while(mainQ.Count > 0)
- {
- Console.Write(mainQ.Dequeue() + ", ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement