【小芳】随机抽人

来源:互联网 发布:网络直播电视下载 编辑:程序博客网 时间:2024/04/27 10:11

小芳上课时说的那个随机抽学号上去写题的代码。

#include<stdio.h>#include<stdlib.h>#include<time.h>int main(){    int i;    int n,m;    srand(time(NULL));     printf("请输入抽取学生人数:\n");    int t;    scanf("%d",&t);    for(i=0;i<t;i++)    {        n=rand()%10+1;        m=rand()%30+1;        printf("%d%d号\n",n,m);    }    return 0;}
0 0