Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Szyfr
- {
- class Program
- {
- static void Main(string[] args)
- {
- LinearFeedbackShiftRegister linearFeedbackShiftRegister = new LinearFeedbackShiftRegister(4);
- while(true)
- {
- Console.WriteLine(linearFeedbackShiftRegister.Generate().ToString());
- Console.ReadLine();
- }
- }
- }
- public class LinearFeedbackShiftRegister
- {
- List<int> List = new List<int>();
- public LinearFeedbackShiftRegister()
- {
- List.Add(0);
- List.Add(1);
- List.Add(1);
- List.Add(0);
- }
- public LinearFeedbackShiftRegister(int n)
- {
- Random random = new Random();
- for (int i = 0; i < n; i++) List.Add(random.Next(0, 2));
- }
- public int Generate()
- {
- int result;
- int add;
- result = List[0];
- if (List[List.Count - 1] == List[0]) add = 0;
- else add = 1;
- List.Add(add);
- List.RemoveAt(0);
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement