Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.66 KB | None | 0 0
  1. using Microsoft.Win32;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17.  
  18. namespace czestosc
  19. {
  20. /// <summary>
  21. /// Interaction logic for MainWindow.xaml
  22. /// </summary>
  23. public partial class MainWindow : Window
  24. {
  25. public MainWindow()
  26. {
  27. InitializeComponent();
  28. }
  29.  
  30. private void wczytaj_plik_Click(object sender, RoutedEventArgs e)
  31. {
  32. OpenFileDialog okienko = new OpenFileDialog(); // do otwierania okna wyboru
  33. okienko.Filter = "Pliki textowe (txt)|*.txt";
  34. okienko.ShowDialog();
  35. StreamReader read = new StreamReader(okienko.FileName);
  36.  
  37.  
  38. wykres.Text = read.ReadToEnd();
  39. }
  40.  
  41. private void textBox_TextChanged(object sender, TextChangedEventArgs e)
  42. {
  43.  
  44.  
  45.  
  46. }
  47.  
  48. private void licz_Click(object sender, RoutedEventArgs e)
  49. {
  50. float ile = 0;
  51. float procent = 0.48F;
  52. float procent2 = 0.52F;
  53. int dl = wykres.Text.Length;
  54.  
  55. for (int i = 0; i < dl; i++)
  56. {
  57. if (wykres.Text[i] == '1')
  58. ile++;
  59. }
  60.  
  61. wynik.Text = "Liczba jedynek w pliktu:";
  62. wynik.Text += ile;
  63.  
  64.  
  65. if (((ile / dl) > procent) && ((ile / dl) < procent2))
  66. {
  67. wynik.Text += "\n test zdany";
  68. }
  69. else
  70. wynik.Text += "\n test niezdany";
  71.  
  72.  
  73.  
  74.  
  75.  
  76. }
  77.  
  78. private void pokerowy_Click(object sender, RoutedEventArgs e)
  79. {
  80. //int[][] cigi = new int[5000][];
  81. int[] ile = new int[16];
  82. string pom = "";
  83. for (int i = 0; i < 20000; i+=4)
  84. {
  85. for (int j = 0; j < 4; j++)
  86. {
  87. pom += wykres.Text[i + j];
  88. }
  89. if (pom == "0000")
  90. ile[0]++;
  91.  
  92. if (pom == "0001")
  93. ile[1]++;
  94.  
  95. if (pom == "0011")
  96. ile[2]++;
  97.  
  98. if (pom == "0101")
  99. ile[3]++;
  100.  
  101. if (pom == "1001")
  102. ile[4]++;
  103.  
  104. if (pom == "0010")
  105. ile[5]++;
  106.  
  107. if (pom == "0110")
  108. ile[6]++;
  109.  
  110. if (pom == "1010")
  111. ile[7]++;
  112.  
  113. if (pom == "0100")
  114. ile[8]++;
  115.  
  116. if (pom == "1100")
  117. ile[9]++;
  118.  
  119. if (pom == "0111")
  120. ile[10]++;
  121.  
  122. if (pom == "1101")
  123. ile[11]++;
  124.  
  125. if (pom == "1011")
  126. ile[12]++;
  127.  
  128. if (pom == "1110")
  129. ile[13]++;
  130.  
  131. if (pom == "1000")
  132. ile[14]++;
  133.  
  134. if (pom == "1111")
  135. ile[15]++;
  136. pom = "";
  137.  
  138. }
  139.  
  140.  
  141. float sigma = ((ile[0] * ile[0]) +
  142. (ile[1] * ile[1]) + (ile[2] * ile[2]) +
  143. (ile[3] * ile[3]) + (ile[4] * ile[4]) +
  144. (ile[5] * ile[5]) + (ile[6] * ile[6]) +
  145. (ile[7] * ile[7]) + (ile[8] * ile[8]) +
  146. (ile[9] * ile[9]) + (ile[10] * ile[10]) +
  147. (ile[11] * ile[11]) + (ile[12] * ile[12]) +
  148. (ile[13] * ile[13]) + (ile[14] * ile[14]) +
  149. (ile[15] * ile[15]));
  150. double pocz = 0.0032;
  151.  
  152. double p = pocz * sigma - 5000;
  153. if (p >= 2.16 && p <= 46.17)
  154. {
  155. wynik.Text = "test pokerowy zdany";
  156. }
  157. else
  158. wynik.Text = "test pokerowy nie zdany";
  159. }
  160.  
  161. private void pary_Click(object sender, RoutedEventArgs e)
  162. {
  163. int a = 0;
  164. 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
  165. string wykres1 = "";
  166. for (int i = 0; i < wykres.Text.Length - 1; i+=2)
  167. {
  168. wykres1 += wykres.Text[i];
  169. wykres1 += wykres.Text[i + 1];
  170.  
  171.  
  172. if (wykres1 == "00")
  173. n00++;
  174. else if (wykres1 == "01")
  175. n01++;
  176. else if (wykres1 == "10")
  177. n10++;
  178. else
  179. n11++;
  180.  
  181. wykres1 = "";
  182. a = i;
  183. }
  184.  
  185. float kontrola = 0;
  186. kontrola = (wykres.Text.Length) / 8;
  187. float kontrola2 = kontrola+((wykres.Text.Length)*0.01F);
  188. kontrola = kontrola - ((wykres.Text.Length) * 0.01F);
  189.  
  190.  
  191. if ((n00 < kontrola2 && n00 > kontrola) && (n01 < kontrola2 && n01 > kontrola) && (n11 < kontrola2 && n11 > kontrola))
  192. wynik.Text = "test par bitów zdany\n";
  193. else
  194. wynik.Text = "test par bitów nie zdany\n";
  195.  
  196. }
  197.  
  198. private void serii_Click(object sender, RoutedEventArgs e)
  199. {
  200. int seria1 = 0;
  201. int seria2 = 0;
  202. int seria3 = 0;
  203. int seria4 = 0;
  204. int seria5 = 0;
  205. int seria6 = 0;
  206. string tekst = wykres.Text;
  207. for (int i = 1; i < 19994; i++)
  208. {
  209. 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])
  210. {
  211. seria6++;
  212. i += 5;
  213. }
  214.  
  215. else
  216. if (tekst[i - 1] == tekst[i] && tekst[i] == tekst[i + 1] && tekst[i + 1] == tekst[i + 2] && tekst[i + 2] == tekst[i + 3])
  217. {
  218. seria5++;
  219. i += 4;
  220. }
  221.  
  222. else
  223. if (tekst[i - 1] == tekst[i] && tekst[i] == tekst[i + 1] && tekst[i+1] == tekst[i + 2])
  224. {
  225. seria4++;
  226. i += 3;
  227. }
  228.  
  229. else
  230.  
  231. if (tekst[i - 1] == tekst[i] && tekst[i] == tekst[i + 1])
  232. {
  233. seria3++;
  234. i += 2;
  235. }
  236. else
  237. if (tekst[i - 1] == tekst[i])
  238. {
  239. seria2++;
  240. i += 1;
  241. }
  242. else seria1++;
  243.  
  244.  
  245.  
  246. }
  247. int flaga = 0;
  248. if (seria1 > 2315 && seria1 < 2685)
  249. flaga += 1;
  250. if (seria2 > 1114 && seria2 < 1386)
  251. flaga += 1;
  252. if (seria3 > 527 && seria3 < 723)
  253. flaga += 1;
  254. if (seria4 > 240 && seria4 < 384)
  255. flaga += 1;
  256. if (seria5 > 103 && seria5 < 209)
  257. flaga += 1;
  258. if (seria6 > 103 && seria6 < 209)
  259. flaga += 1;
  260.  
  261. if (flaga == 6)
  262. wynik.Text = "test serii pozytywny";
  263. else
  264. wynik.Text = "test serii nie zdany";
  265.  
  266.  
  267.  
  268. }
  269. }
  270. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement