怎么样把一段文章里面的字顺序打乱?

怎么把一段文章里里的所有字顺序打乱?成为一个一个单个的字?
比如说

一段文章是:今天天气好。
打乱顺序还是这几个字,顺序变不一样了,变成:气今天好天,或者别的顺序,反正跟以前的顺序不一样,但字的个数不变。

就好像一幢房子,我要把它拆成一块一块的砖一样,这么说明白了吗?

比如说一篇5000字的文章,我要把里面的字完全打乱,没成没有意义的5000个字,标点也一起打乱,用什么办法?

下面是用程序(C语言)
将文章保存为d:\article.txt文件。 生成的打乱文件将在d:\new_art.txt

你如果没有编译器的话,你留下邮箱,我将生成的exe文件发给你。

然后运行一下代码生成的可执行程序即可。
/*****************************************************************
*Author :wacs5
*Date :20081230(YYYYMMDD)
*Function :
* 打乱文章顺序(文章篇幅不多于8000字)
*input data :d:\article.txt
*output data :d:\new_art.txt
****************************************************************/
#include <time.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#define MAXCHR 8000 /*最大处理8000个汉字*/

main()
{
char *text;
int *loc,*flag;
int i,count,readchr,rndord,temp;
fpos_t filelen;

FILE *fp,*fpout;

srand((unsigned)time(NULL));
fp=fopen("d:\\article.txt","r");
fpout=fopen("d:\\new_art.txt","w");
if (fp==NULL)
{
printf("ERROR: File Open Error:\nPress any key to exit:");
getch();
exit(1);
}
fseek(fp,0,SEEK_END); /*reach the End of File*/
fgetpos(fp,&filelen);
if (filelen>MAXCHR)
{
printf("ERROR: The Article is too big:\nPress any key to exit:");
getch();
exit(1);
}

text=(char *) calloc(filelen+20,sizeof(char));
loc =(int *) calloc(filelen+20,sizeof(int ));
flag=(int *) calloc(filelen+20,sizeof(int ));
if (text==NULL || loc==NULL || flag==NULL)
{
printf("ERROR: No enough Memory:\nPress any key to exit:");
getch();
exit(1);
}
for (i=0;i<filelen;i++)
loc[i]=flag[i]=0;

memset(text,'\0',filelen);
fseek(fp,0,SEEK_SET); /*Go to the beginning of the file*/
readchr=fread(text,sizeof(char),filelen,fp);
printf("filelen=%ld\nreadchr=%d\n",filelen,readchr);

i=0; /*读text内容的序号*/
count=0; /*文章中有多少个字(一个英文、一个汉字都算一个字)*/
while(i<readchr)
{
if (text[i]&0x80)
{
flag[count]=1; /*标记一下,这个位置为汉字*/
loc[count++]=i; /*记住位置*/
i+=2;
}
else
{
loc[count++]=i;
i++;
}
}

for (i=0;i<count;i++)
{
rndord=rand()%(count-i);
/*输出rndord的字(英文或中文)*/
if (flag[rndord])
fprintf(fpout,"%c%c",text[loc[rndord]],text[loc[rndord]+1]);
else
fprintf(fpout,"%c",text[loc[rndord]]);

temp=loc[count-i-1];
loc[count-i-1]=loc[rndord];
loc[rndord]=temp;

temp=flag[count-i-1];
flag[count-i-1]=flag[rndord];
flag[rndord]=temp;
}

free(text);
free(loc);
free(flag);
fclose(fp);
printf("OK\n");
getch();
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-12-31
你从最后一个字开始,剪切最后一个字,粘贴到第一个字后面!再弄倒数第二个字,粘贴到第三个字后面! 反正就是这么个理论,可以省掉你一半的时间!
第2个回答  2008-12-30
按住ALT键,同时选某块文字,然后随意拖到任意地方,再重复做,直到你满意为止。其他方法好像没有,微软没设计这个程序。
第3个回答  2008-12-30
随便复制一些字符,然后剪切后粘贴到别的地方,反复几次就打乱顺序了
第4个回答  2008-12-31
那就把这些文字进行剪切粘贴就行了,非常简单的
相似回答