Advertisement
Guest User

type fast fail

a guest
Jul 29th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <cstdio>
  2. #include <time.h>
  3. #include <cstring>
  4. #include <stdlib.h>
  5.  
  6. #define NUM 7
  7.  
  8.  
  9. long int tempo1, tempo2;
  10.  
  11. char words[NUM][12]= {"#include\n", "#define\n", "int main()\n", "return x;\n", "if()\n", "else\n", "while()\n"}, word[12];
  12.  
  13. int main(){
  14.   srand(time(NULL));
  15.         tempo1= time(NULL);
  16.         tempo2= tempo1 + 60;
  17.         printf("%ld\n", tempo1);
  18.         int idx, co= 0, er= 0;
  19.         while(tempo1 <= tempo2){
  20.                 idx= rand() % NUM;
  21.                 printf("%s", words[idx]);
  22.                 fgets(word, 12, stdin);
  23.                 printf("\n");
  24.                 strcmp(words[idx], word) ? er+=1 : co+= 1;
  25.                 tempo1= time(NULL);
  26.         }
  27.         printf("Corretas: %d;\nErradas: %d;\nTotal: %d;\n", co, er, co+er);
  28.         return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement