Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <stdio.h>
- #include <time.h>
- #include <iostream>
- using namespace std;
- int main()
- {
- clock_t t_ini, t_fin;
- clock_t t_ini2, t_fin2;
- double tespera,nletra,secs,secs2;
- char letra,x;
- int N=0;
- float tms=0,n,media=0;
- cout<<"Solo tienes que teclear lo que veas por pantalla"<<endl<<"--> Asegurate de que BLOCK MAYUS esta OFF <--"<<endl<<"Cuando estes listo introduce el numero de pruebas para comenzar: ";
- cin>>n;
- cout<<endl<<endl;
- if (n<=0) {
- cout<<"n=1 para evitar errores";
- n=1;
- }
- while (N<n)
- {
- N++;
- t_ini = clock();
- srand (clock());
- tespera = rand()%50;
- tespera= tespera/10;
- nletra = rand()%25;
- nletra=nletra+97;
- letra=char(nletra);
- do {
- t_fin = clock();
- secs = (double)(t_fin - t_ini) / CLOCKS_PER_SEC;
- } while(secs<tespera);
- printf("%c", letra);
- t_ini2 = clock();
- while(x!=letra){
- x=getch();
- }
- t_fin2 = clock();
- secs2 = (double)(t_fin2 - t_ini2) / CLOCKS_PER_SEC;
- printf(" --> %.16g milisegundos\n\n", secs2 * 1000.0);
- tms=tms+secs2;
- }
- media=1000*tms/n;
- cout<<endl<<endl<<"Tu media es de: "<<media<<"ms. Pulsa cualquier tecla para salir.";
- cin>>n;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement