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.Numerics;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void test_serii_dlugiej(String str, int n)
- {
- for (int i = 0; i<str.Length; i++)
- {
- }
- }
- static void test_serii()
- {
- // wszystkie serie dla 1 i 0/
- }
- static void test_pokerowy(String str)
- {
- Dictionary<int, int> num = new Dictionary<int, int>();
- for (int i = 0; i < 16; i++)
- {
- num.Add(i, 0);
- }
- for (int i = 0; i + 4 < str.Length; i += 4)
- {
- String s = str.Substring(i, 4);
- int dec = Convert.ToInt32(s, 2);
- num[dec]++;
- }
- for (int i = 0; i < 16; i++)
- {
- Console.WriteLine("liczba " + i + " wystapienia: " + num[i]);
- }
- }
- static void Main(string[] args)
- {
- Int64 a = 11; //best 30
- Int64 p = 8609; //best 89
- Random r = new Random();
- Int64 x = r.Next() % p;
- BigInteger xi = x;
- Console.WriteLine("x0 " + xi);
- StringBuilder s = new StringBuilder();
- for (int i = 0; i < 20000; i++)
- {
- if (xi > (p - 1) / 2) s.Append("1");
- else s.Append("0");
- xi = BigInteger.ModPow(a, xi, p);
- }
- String str = s.ToString();
- int jeden = str.Split('1').Length - 1 ;
- int zero = str.Split('0').Length - 1 ;
- Console.WriteLine(s);
- Console.WriteLine("jedynki " + jeden);
- Console.WriteLine("zera " + zero);
- test_pokerowy(str);
- //szyfr strumieniowy modulo 2
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement