Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- int prob=10;
- void menu();
- void test1(int p);
- int main() {
- srand(time(NULL));
- menu();
- return 0;
- }
- void menu()
- {
- int z;
- printf("Menu \n");
- printf("1. Liczba prob (10) \n");
- printf("2. Zestaw znakow A...Z\n");
- printf("3. Zestaw znakow A...Z a...z \n");
- printf("4. Zestaw znakow A...Z a...z 0...9\n");
- printf("5. Wszystkie znaki\n");
- printf("0. Koniec\n");
- scanf("%d",&z);
- system("cls");
- switch(z)
- {
- case 1:
- scanf("%i",&prob);
- break;
- case 2:
- test1(prob);
- break;
- case 3:
- test2(prob);
- break;
- case 4:
- test3(prob);
- break;
- case 5:
- test4(prob);
- break;
- case 0:
- return 0;
- }
- }
- void test1(int p)
- {
- int i;
- char odp,y;
- int w=0;
- int t0=time(NULL);
- for(i=0;i<p;i++)
- {
- int j=rand()%26;
- y=65+j;
- printf("%c \n",y);
- odp=getch();
- if(y==odp)
- {
- w++;
- }
- }
- int t1=time(NULL);
- printf("Wynik: %i\n ",w);
- printf("Czas : %i\n ",t1-t0);
- }
- void test2(int p)
- {
- int i;
- char odp,y;
- int w=0;
- int t0=time(NULL);
- for(i=0;i<p;i++)
- {
- int j=rand()%58;
- y=65+j;
- if(y>=91 && y<=96)
- {
- int j=rand()%58;
- y=65+j;
- }
- printf("%c \n",y);
- odp=getch();
- if(y==odp)
- {
- w++;
- }
- }
- int t1=time(NULL);
- printf("Wynik: %i\n ",w);
- printf("Czas : %i\n ",t1-t0);
- }
- void test3(int p)
- {
- int i;
- char odp,y;
- int w=0;
- int t0=time(NULL);
- for(i=0;i<p;i++)
- {
- int j=rand()%74;
- y=65+j;
- if(y>=91 && y<=96 && y>=58 && y<=64)
- {
- int j=rand()%58;
- y=48+j;
- }
- printf("%c \n",y);
- odp=getch();
- if(y==odp)
- {
- w++;
- }
- }
- int t1=time(NULL);
- printf("Wynik: %i\n ",w);
- printf("Czas : %i\n ",t1-t0);
- }
- void test4(int p)
- {
- int i;
- char odp,y;
- int w=0;
- int t0=time(NULL);
- for(i=0;i<p;i++)
- {
- y=rand()%127;
- printf("%c \n",y);
- odp=getch();
- if(y==odp)
- {
- w++;
- }
- }
- int t1=time(NULL);
- printf("Wynik: %i\n ",w);
- printf("Czas : %i\n ",t1-t0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement