代码贴上:

#include <stdlib.h>
#include
<string.h>
#include
<time.h>
#include
<iostream>

// using namespace std;

int main()
{
const char *c = "0123456789abcdefghijklmnopqrstuvwxyz";

srand(static_cast
<unsigned int>(time(NULL)));
std::cout
<< "The random char array is:";
for(int i = 0; i < 5; ++i)
{
std::cout
<< std::endl;
int index = 0 ;
for(int j = 0; j < 5; ++j)
{
index
= rand() % strlen(c);
std::cout
<< c[index ]
<< c[index]
<< " ";
}
}
std::cout
<< std::endl;
return 0;
}

运行效果如下:

The random char array is:
00 qq 88 ii zz
qq bb oo 00 yy
rr yy tt ww ll
ss rr aa bb oo
11 yy tt 33 uu
请按任意键继续. . .

相关文章:

  • 2021-09-29
  • 1970-01-01
  • 2021-07-05
  • 2022-12-23
  • 2022-02-17
  • 2021-12-24
  • 2022-12-23
  • 2021-06-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2021-11-07
  • 2022-12-23
相关资源
相似解决方案