计算三个数的和

#include <time.h>
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int stage;
    int a, b, c;            
    int x;                    
    int n;                    
    clock_t    start, end;    

    srand(time(NULL));    

    printf("input the result \n");
    start = clock();            

    for (stage = 0; stage < 10; stage++) {
        a = 10 + rand() % 90;    
        b = 10 + rand() % 90;        
        c = 10 + rand() % 90;    
        n = rand() % 17;        

        printf("%d%*s+%*s%d%*s+%*s%d  =", a, n, "", n, "", b, n, "", n, "", c);

        do {
            scanf("%d", &x);
            if (x == a + b + c)
                break;
            printf("\awrong,input again!");
        } while (1);
    }

    end = clock();                

    printf("hello world\n", (double)(end - start) / CLOCKS_PER_SEC);

    return 0;
}

猜你喜欢

转载自www.cnblogs.com/sea-stream/p/11037644.html