求助

灌水区

PrincessQi @ 2020-11-29 11:51:29

有大佬有随机生成汉字的代码吗(

自己写的锅了 /fad

bd上也没有可用的


by Lonely_NewYear @ 2020-11-29 12:01:14

@Dr冯

#include <fstream>
#include <iostream>
#include<time.h> 
#include<stdlib.h> 
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    srand((unsigned)time(NULL));
    int iRange1 = 0xf7 - 0xb0;
    int iRange2 = 0xfe - 0xa1;
    for(int i=1;i<=n;i++)
    {
        char iCode1 = rand()%iRange1 + 0xb0;
        char iCode2 = rand()%iRange2 + 0xa1;
        char ch[3] = {iCode1,iCode2,0};
        cout<<ch<<endl<<endl<<endl;
    }
    return 0;
}

by Lonely_NewYear @ 2020-11-29 12:01:45

https://blog.csdn.net/henren555/article/details/9347499


by PrincessQi @ 2020-11-29 12:04:20

@fanglong 这个能用吗(我这边测不能?


by Lonely_NewYear @ 2020-11-29 12:05:53

@Dr冯 我这边可以(


by PrincessQi @ 2020-11-29 12:07:23

@fanglong /fad


by Krystallos @ 2020-11-29 12:26:19

@Dr冯 不同环境下中文编码是不同的,很有可能这个环境下是正常的中文字符到另一个环境下就成了乱码


by PrincessQi @ 2020-11-29 14:03:56

@Krystallos /fad

这边linux ubuntu18.04


|