博客园 :: :: 博问 :: 闪存 :: 新随笔 :: :: :: 管理 ::
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() 
{
    char str[95];
    char pstr[11];
    int i;
    int x;
    int y;
    srand((unsigned) time(0));

    for (i = 0; i < 95; i++) 
    {
        str[i] = (char)(i + 33);
    }

    for (y = 0; y < 10; y++) 
    {
        for (i = 0; i < 10; i++) 
        {
            x = rand() % 94;
            pstr[i] = str[x];
        }

        pstr[10] = '\0'; //防止越界出现“烫”。
        printf("%s\n", pstr);
    }
    return 0;
}

 

posted on 2016-01-12 13:42  #include<stdio.h>  阅读(275)  评论(0编辑  收藏  举报