Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Collections;
- namespace fibonacci
- {
- class Program
- {
- static void Main(string[] args)
- {
- Queue<int> fib = new Queue<int>();
- Console.Write("Kolikate cislo: ");
- int index = int.Parse(Console.ReadLine());
- fib.Enqueue(0);
- fib.Enqueue(1);
- for (int i = 0; i < index - 1; i++)
- {
- fib.Enqueue(fib.Dequeue() + fib.Peek());
- }
- fib.Dequeue();
- Console.Write("{0}. prvek: {1}",index,fib.Peek());
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement