Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <signal.h>
- #include <unistd.h>
- int jo=0, rossz=0;
- void vege (int s){
- printf("Jo valaszok szama: ",jo);
- printf("Rossz valaszok szama: ",rossz);
- }
- int main()
- {
- srand(time(NULL));
- int tipp, eredmeny;
- int a,b;
- while(1){
- a = (rand ()%101);
- b = (rand ()%101);
- fprintf(stdout,"%d+%d=?\n",a,b);
- signal(SIGALRM,vege);
- alarm(12);
- eredmeny = a+b;
- fprintf(stdout,"Tipp: ");
- fscanf(stdin,"%d",&tipp);
- if (tipp == eredmeny){
- printf("\nJo a megoldas!\n\n");
- jo++;
- }
- else {
- printf("\nRossz a megoldas!\n\n");
- rossz++;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement