Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Win32;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace czestosc
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- private void wczytaj_plik_Click(object sender, RoutedEventArgs e)
- {
- OpenFileDialog okienko = new OpenFileDialog(); // do otwierania okna wyboru
- okienko.Filter = "Pliki textowe (txt)|*.txt";
- okienko.ShowDialog();
- StreamReader read = new StreamReader(okienko.FileName);
- wykres.Text = read.ReadToEnd();
- }
- private void textBox_TextChanged(object sender, TextChangedEventArgs e)
- {
- }
- private void licz_Click(object sender, RoutedEventArgs e)
- {
- float ile = 0;
- float procent = 0.48F;
- float procent2 = 0.52F;
- int dl = wykres.Text.Length;
- for (int i = 0; i < dl; i++)
- {
- if (wykres.Text[i] == '1')
- ile++;
- }
- wynik.Text = "Liczba jedynek w pliktu:";
- wynik.Text += ile;
- if (((ile / dl) > procent) && ((ile / dl) < procent2))
- {
- wynik.Text += "\n test zdany";
- }
- else
- wynik.Text += "\n test niezdany";
- }
- private void pokerowy_Click(object sender, RoutedEventArgs e)
- {
- //int[][] cigi = new int[5000][];
- int[] ile = new int[16];
- string pom = "";
- for (int i = 0; i < 20000; i+=4)
- {
- for (int j = 0; j < 4; j++)
- {
- pom += wykres.Text[i + j];
- }
- if (pom == "0000")
- ile[0]++;
- if (pom == "0001")
- ile[1]++;
- if (pom == "0011")
- ile[2]++;
- if (pom == "0101")
- ile[3]++;
- if (pom == "1001")
- ile[4]++;
- if (pom == "0010")
- ile[5]++;
- if (pom == "0110")
- ile[6]++;
- if (pom == "1010")
- ile[7]++;
- if (pom == "0100")
- ile[8]++;
- if (pom == "1100")
- ile[9]++;
- if (pom == "0111")
- ile[10]++;
- if (pom == "1101")
- ile[11]++;
- if (pom == "1011")
- ile[12]++;
- if (pom == "1110")
- ile[13]++;
- if (pom == "1000")
- ile[14]++;
- if (pom == "1111")
- ile[15]++;
- pom = "";
- }
- float sigma = ((ile[0] * ile[0]) +
- (ile[1] * ile[1]) + (ile[2] * ile[2]) +
- (ile[3] * ile[3]) + (ile[4] * ile[4]) +
- (ile[5] * ile[5]) + (ile[6] * ile[6]) +
- (ile[7] * ile[7]) + (ile[8] * ile[8]) +
- (ile[9] * ile[9]) + (ile[10] * ile[10]) +
- (ile[11] * ile[11]) + (ile[12] * ile[12]) +
- (ile[13] * ile[13]) + (ile[14] * ile[14]) +
- (ile[15] * ile[15]));
- double pocz = 0.0032;
- double p = pocz * sigma - 5000;
- if (p >= 2.16 && p <= 46.17)
- {
- wynik.Text = "test pokerowy zdany";
- }
- else
- wynik.Text = "test pokerowy nie zdany";
- }
- private void pary_Click(object sender, RoutedEventArgs e)
- {
- int a = 0;
- int n00 = 0, n01 = 0, n10 = 0, n11 = 0; //liczba 00 wciągu, liczba 01 wciągu, liczba 10 wciągu, liczba 11 wciągu
- string wykres1 = "";
- for (int i = 0; i < wykres.Text.Length - 1; i+=2)
- {
- wykres1 += wykres.Text[i];
- wykres1 += wykres.Text[i + 1];
- if (wykres1 == "00")
- n00++;
- else if (wykres1 == "01")
- n01++;
- else if (wykres1 == "10")
- n10++;
- else
- n11++;
- wykres1 = "";
- a = i;
- }
- float kontrola = 0;
- kontrola = (wykres.Text.Length) / 8;
- float kontrola2 = kontrola+((wykres.Text.Length)*0.01F);
- kontrola = kontrola - ((wykres.Text.Length) * 0.01F);
- if ((n00 < kontrola2 && n00 > kontrola) && (n01 < kontrola2 && n01 > kontrola) && (n11 < kontrola2 && n11 > kontrola))
- wynik.Text = "test par bitów zdany\n";
- else
- wynik.Text = "test par bitów nie zdany\n";
- }
- private void serii_Click(object sender, RoutedEventArgs e)
- {
- int seria1 = 0;
- int seria2 = 0;
- int seria3 = 0;
- int seria4 = 0;
- int seria5 = 0;
- int seria6 = 0;
- string tekst = wykres.Text;
- for (int i = 1; i < 19994; i++)
- {
- if (tekst[i - 1] == tekst[i] && tekst[i] == tekst[i + 1] && tekst[i + 1] == tekst[i + 2] && tekst[i + 2] == tekst[i + 3] && tekst[i + 3] == tekst[i + 4])
- {
- seria6++;
- i += 5;
- }
- else
- if (tekst[i - 1] == tekst[i] && tekst[i] == tekst[i + 1] && tekst[i + 1] == tekst[i + 2] && tekst[i + 2] == tekst[i + 3])
- {
- seria5++;
- i += 4;
- }
- else
- if (tekst[i - 1] == tekst[i] && tekst[i] == tekst[i + 1] && tekst[i+1] == tekst[i + 2])
- {
- seria4++;
- i += 3;
- }
- else
- if (tekst[i - 1] == tekst[i] && tekst[i] == tekst[i + 1])
- {
- seria3++;
- i += 2;
- }
- else
- if (tekst[i - 1] == tekst[i])
- {
- seria2++;
- i += 1;
- }
- else seria1++;
- }
- int flaga = 0;
- if (seria1 > 2315 && seria1 < 2685)
- flaga += 1;
- if (seria2 > 1114 && seria2 < 1386)
- flaga += 1;
- if (seria3 > 527 && seria3 < 723)
- flaga += 1;
- if (seria4 > 240 && seria4 < 384)
- flaga += 1;
- if (seria5 > 103 && seria5 < 209)
- flaga += 1;
- if (seria6 > 103 && seria6 < 209)
- flaga += 1;
- if (flaga == 6)
- wynik.Text = "test serii pozytywny";
- else
- wynik.Text = "test serii nie zdany";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement