1. 程式人生 > >C++隨機生成漢字

C++隨機生成漢字

#include <fstream>
#include <iostream>
using namespace std;
#include<time.h> 
#include<stdlib.h> 

int main(){

srand((unsigned)time(NULL));
int iRange1 = 0xf7 - 0xb0;
int iRange2 = 0xfe - 0xa1;
for (int i=0;i<10;++i)
{
char iCode1 = rand()%iRange1 + 0xb0;
char iCode2 = rand()%iRange2 + 0xa1;
char ch[3] = {iCode1,iCode2,0};
cout<<ch<<endl;
}
return 0;
}