Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5.  
  6.  
  7. int prob=10;
  8.  
  9. void menu();
  10.  
  11. void test1(int p);
  12. int main() {
  13. srand(time(NULL));
  14.  
  15. menu();
  16. return 0;
  17. }
  18.  
  19.  
  20. void menu()
  21. {
  22. int z;
  23.  
  24. printf("Menu \n");
  25. printf("1. Liczba prob (10) \n");
  26. printf("2. Zestaw znakow A...Z\n");
  27. printf("3. Zestaw znakow A...Z a...z \n");
  28. printf("4. Zestaw znakow A...Z a...z 0...9\n");
  29. printf("5. Wszystkie znaki\n");
  30. printf("0. Koniec\n");
  31.  
  32. scanf("%d",&z);
  33.  
  34. system("cls");
  35.  
  36. switch(z)
  37. {
  38.  
  39. case 1:
  40. scanf("%i",&prob);
  41. break;
  42. case 2:
  43. test1(prob);
  44. break;
  45. case 3:
  46. test2(prob);
  47. break;
  48. case 4:
  49. test3(prob);
  50. break;
  51. case 5:
  52. test4(prob);
  53. break;
  54. case 0:
  55. return 0;
  56. }
  57. }
  58.  
  59.  
  60. void test1(int p)
  61. {
  62.  
  63. int i;
  64. char odp,y;
  65.  
  66. int w=0;
  67.  
  68. int t0=time(NULL);
  69.  
  70. for(i=0;i<p;i++)
  71. {
  72.  
  73. int j=rand()%26;
  74.  
  75. y=65+j;
  76.  
  77. printf("%c \n",y);
  78.  
  79. odp=getch();
  80.  
  81. if(y==odp)
  82. {
  83. w++;
  84. }
  85.  
  86. }
  87.  
  88. int t1=time(NULL);
  89.  
  90. printf("Wynik: %i\n ",w);
  91.  
  92. printf("Czas : %i\n ",t1-t0);
  93.  
  94. }
  95.  
  96.  
  97. void test2(int p)
  98. {
  99.  
  100. int i;
  101. char odp,y;
  102.  
  103. int w=0;
  104.  
  105. int t0=time(NULL);
  106.  
  107. for(i=0;i<p;i++)
  108. {
  109.  
  110. int j=rand()%58;
  111.  
  112. y=65+j;
  113.  
  114. if(y>=91 && y<=96)
  115. {
  116. int j=rand()%58;
  117.  
  118. y=65+j;
  119. }
  120.  
  121.  
  122. printf("%c \n",y);
  123.  
  124. odp=getch();
  125.  
  126. if(y==odp)
  127. {
  128. w++;
  129. }
  130.  
  131. }
  132.  
  133. int t1=time(NULL);
  134.  
  135. printf("Wynik: %i\n ",w);
  136.  
  137. printf("Czas : %i\n ",t1-t0);
  138.  
  139. }
  140.  
  141.  
  142. void test3(int p)
  143. {
  144.  
  145. int i;
  146. char odp,y;
  147.  
  148. int w=0;
  149.  
  150. int t0=time(NULL);
  151.  
  152. for(i=0;i<p;i++)
  153. {
  154.  
  155. int j=rand()%74;
  156.  
  157. y=65+j;
  158.  
  159. if(y>=91 && y<=96 && y>=58 && y<=64)
  160. {
  161. int j=rand()%58;
  162.  
  163. y=48+j;
  164. }
  165.  
  166.  
  167. printf("%c \n",y);
  168.  
  169. odp=getch();
  170.  
  171. if(y==odp)
  172. {
  173. w++;
  174. }
  175.  
  176. }
  177.  
  178. int t1=time(NULL);
  179.  
  180. printf("Wynik: %i\n ",w);
  181.  
  182. printf("Czas : %i\n ",t1-t0);
  183.  
  184. }
  185.  
  186.  
  187. void test4(int p)
  188. {
  189.  
  190. int i;
  191. char odp,y;
  192.  
  193. int w=0;
  194.  
  195. int t0=time(NULL);
  196.  
  197. for(i=0;i<p;i++)
  198. {
  199.  
  200. y=rand()%127;
  201.  
  202.  
  203. printf("%c \n",y);
  204.  
  205. odp=getch();
  206.  
  207. if(y==odp)
  208. {
  209. w++;
  210. }
  211.  
  212. }
  213.  
  214. int t1=time(NULL);
  215.  
  216. printf("Wynik: %i\n ",w);
  217.  
  218. printf("Czas : %i\n ",t1-t0);
  219.  
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement