#include <stdio.h>#include <time.h>#include <stdlib.h>void main(){ int i =0; int scores[5]; int num; int s=0; srand((unsigned)time(NULL)); for(i=0;i<10;i++) { num=rand()%10+1; scores[i]=num; s=scores[i]; } for(i=0;i<10;i++){ if(s>scores[i]) s=scores[i]; } printf("%d\n",scores[i]); printf("%d\n",s);
1 回答
Lemon156
TA贡献91条经验 获得超32个赞
#include <stdio.h> #include <time.h> #include <stdlib.h> void main() { int i =0; int scores[10]; int s=0; srand((unsigned)time(NULL)); for(i=0;i<10;i++) { scores[i]=rand()%100+1; } s=scores[0]; for(i=1;i<10;i++){ //找最值 if(scores[i]>s){ s=scores[i]; } } for(i=0;i<10;i++){ printf("%d ",scores[i]); } printf("\n%d\n",s); }
- 1 回答
- 0 关注
- 1232 浏览
添加回答
举报
0/150
提交
取消