请使用rand函数,来写一个上午上课随机点名的小程序,
要求执行该程序后会输出被提问学生的学号。
(注意,咱班有45个人,学号为1~45)
/* Note:Your choice is C IDE */
#include "stdio.h"
#include "stdlib.h"
main()
{
int ia,ib;
ia=rand();
if(1<=ia&&ia<=45)
{ printf("the student is %d\n",ia);}
else
{ib=(ia%45)+1;
printf("the student is %d\n",ib);} }
随机点一个学号
最新推荐文章于 2022-12-26 15:21:24 发布