阅读背景:

C语言学习Day15

来源:互联网 

一、rand随机函数的使用

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

//随机洗牌程序
int main()
{
    int i = 0;
    int arr[54] = { 0 };
    int mark[55] = { 0 };
    srand((unsigned int)time(NULL));
    while (i < 54) {
        int x = rand() % 54 + 1;
        if (mark[x] == 1) {
            continue;
        }
        arr[i] = x;
        mark[x] = 1;
        printf("%d\t", arr[i]);
        i++;
    }

    return 0;
}#include <stdio.h>
#include <tim



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: