1. #include<stdlib.h>   
  2. #include<stdio.h>   
  3. main()   
  4. {   
  5.  int a,b,c,x=0;   
  6.  while(x<5)   
  7.  {a=rand()%100;   
  8.   b=rand()%100;   
  9.   if(a+b>100)   
  10.       continue;   
  11.   printf("\\n%d+%d=? ",a,b);   
  12.   scanf("%d",&c);   
  13.   if(c==a+b)   
  14.   {printf("the answer is right");   
  15.   x++;   
  16.   }   
  17.   else   
  18.   {printf("The answer is wrong");x=0;   
  19.      
  20.   }   
  21.     
  22.  }printf("\\n program is over");   
  23.    
  24. }   

 本文转载自http://www.itjianghu.net/120109/40917409722222265.htm