當前位置:編程學習大全網 - 編程軟體 - 編程,在屏幕上隨機列出10道加法計算題,請用戶輸入答案,每題10分,最後列出分值。

編程,在屏幕上隨機列出10道加法計算題,請用戶輸入答案,每題10分,最後列出分值。

#include <stdlib.h>

#include <stdio.h>

#include <time.h>

int add(x,y)

{int s;

s=x+y;

return s;

}

void srand(int x,int y)

{ srand( (unsigned)time( NULL ) ); /*這個就是生成了壹個種子*/

x=rand()%100; /*通過rand()%100來生成壹個0~99的隨機數,並將它賦給k*/

y=rand()%100;

}

main()

{int i,sum=0;

int x,y;

printf("please count these questions\n");

for(i=0;i<10;i++)

{long c;

srand(x,y) ;

add(x,y);

printf("x+y=");

scanf("%ld",&c);

if(c=add(x,y))sum+=10;

}

printf("Your score is %d:\n",sum);

}

  • 上一篇:常用的可編程邏輯器件的開發環境有哪些
  • 下一篇:焊接的發音是什麽?
  • copyright 2024編程學習大全網