005
09.05.2003, 12:20 Uhr
~Heiko
Gast
|
Ok ich nehme dann mal kleinbuchstaben
C++: |
#include "stdlib.h" #include "stdio.h" #include "time.h"
int getRandomletter(){
int letterdistribution[26]={647,193,268,483,1748,165,306,423,773,27,146,349,258,984,298,96,2,754,683,613,417,94,148,4,8,114};
int i,rv, help, help2; rv = 65; help2=letterdistribution[0];;
help=0; for(i=0;i<26;i++) help+=letterdistribution[i]; help=rand()%help; i=0; while(true) if(help>help2){i++;rv++;help2+=letterdistribution[i];}else break;
return rv+32;
}
int main(){
FILE *fp; int help;
fp=fopen("test.txt","wb");
srand(time(NULL));
for(int i=0;i<1000;i++){ help=rand()%10; if(help<5)help=1; else if(help<8)help=2; else help=3;
for(int j=0;j<help;j++){ for(int k=0;k<rand()%5+3;k++){ for(int l=0;l<rand()%9+2;l++){ fprintf(fp,"%c",getRandomletter()); } fprintf(fp," "); } fseek(fp,-1,SEEK_CUR); fprintf(fp,", "); } fseek(fp,-2,SEEK_CUR); fprintf(fp,". "); }
fclose(fp);
return 0;
}
|
|