标题:请问C如何随机生成[10,25000]的字符串数组???拜托各位大佬🙏!! ...
只看楼主
宋致言
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2019-12-17
 问题点数:0 回复次数:1 
请问C如何随机生成[10,25000]的字符串数组???拜托各位大佬🙏!!
请问C如何随机生成[10,25000]的字符串数组???拜托各位大佬🙏!!
搜索更多相关主题的帖子: 字符串 数组 随机 生成 
2019-12-17 18:22
宋致言
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2019-12-17
得分:0 
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<conio.h>
#define random(x)(rand()%x)
#define N 5


int main()
{
    srand(1);
    int flag,charLengt;
    int i,j,k=0;
    char ch[N+1]={NULL};
    char zh[N+1]={NULL};
    srand((unsigned)time(NULL));
    srand(time(NULL));
        for(i=0;i<25000;i++){
        for(j=0;j<N;j++){
            flag=rand()%2;
            if(flag)ch[k++]='A'+rand()%26;
            else ch[k++]='a'+rand()%26;
        }   
        ch[k]='\0';
        k=0;
    printf("%d %s %s %s %s %s %s %s %s %s\n",rand(),ch,ch,ch,ch,ch,ch,ch,ch,ch);
    }
   
}
2019-12-21 15:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-498467-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.243794 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved