文件名称:normaldistribution
介绍说明--下载内容均来自于网络,请自行研究使用
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <fstream>
#include <iostream>
using namespace std
struct Code
{
float a
char s
}
Code cc[8]={{0.25, a },{0.3, b },{0.1, c },{0.05, d },{0.05, e },{0.05, . },{0.05, , },{0.15, 8 }}
int main()
{
srand((unsigned)time(NULL))
int x
int n
ofstream outobj("plpl.txt")
cout<<"inpute the number(要产生的字符数):"
cin>>n
for(int i=0 i<n i++)
{
x=rand()%1000+1
int low =1
for(int j=0 j<8 j++)
{
int high=cc[j].a*1000+low-1
if(x>=low&&x<=high)
{
outobj<<cc[j].s
break
}
low = high+1
}
}
outobj.flush()
outobj.close()
} 存到.dat文件里面-# Include <stdlib.h># Include <stdio.h># Include <time.h># Include <fstream># Include <iostream> using namespace std struct Code (float a char s) Code cc [ 8] = ((0.25, a), (0.3, b), (0.1, c), (0.05, d), (0.05, e), (0.05,.), (0.05,,), (0.15, 8 )) int main () (srand ((unsigned) time (NULL)) int x int n ofstream outobj ( plpl.txt ) cout << inpute the number (to generate the number of characters): cin>> n for (int i = 0 i <n i++) (x = rand () 1000+ 1 int low = 1 for (int j = 0 j <8 j++) (int high = cc [j] . a* 1000+ low-1 if (x> = low
#include <stdio.h>
#include <time.h>
#include <fstream>
#include <iostream>
using namespace std
struct Code
{
float a
char s
}
Code cc[8]={{0.25, a },{0.3, b },{0.1, c },{0.05, d },{0.05, e },{0.05, . },{0.05, , },{0.15, 8 }}
int main()
{
srand((unsigned)time(NULL))
int x
int n
ofstream outobj("plpl.txt")
cout<<"inpute the number(要产生的字符数):"
cin>>n
for(int i=0 i<n i++)
{
x=rand()%1000+1
int low =1
for(int j=0 j<8 j++)
{
int high=cc[j].a*1000+low-1
if(x>=low&&x<=high)
{
outobj<<cc[j].s
break
}
low = high+1
}
}
outobj.flush()
outobj.close()
} 存到.dat文件里面-# Include <stdlib.h># Include <stdio.h># Include <time.h># Include <fstream># Include <iostream> using namespace std struct Code (float a char s) Code cc [ 8] = ((0.25, a), (0.3, b), (0.1, c), (0.05, d), (0.05, e), (0.05,.), (0.05,,), (0.15, 8 )) int main () (srand ((unsigned) time (NULL)) int x int n ofstream outobj ( plpl.txt ) cout << inpute the number (to generate the number of characters): cin>> n for (int i = 0 i <n i++) (x = rand () 1000+ 1 int low = 1 for (int j = 0 j <8 j++) (int high = cc [j] . a* 1000+ low-1 if (x> = low
(系统自动生成,下载前可以参看下载内容)
下载文件列表
normaldistribution.txt