📄 随机数函数.cpp
字号:
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
#include<stdlib.h>
#include<iomanip.h>//setw()
#define max 100
typedef struct {
int s[max][max];//用二维数组存放教师专业特长
int D[max]; //用一维数组存放安排的教学任务
}MGraph;
void sjcount(MGraph &G, int n)
{srand((unsigned int)time((time_t *)NULL));//srand() 来初始化伪随机数发生器的种子,(当前时间)
for (int i=1;i<=n;i++){
for (int s=1;s<=n;s++)
{G.s[i][s]=rand() % 2;
cout<<G.s[i][s]<<endl;
}
}
}
void main()
{MGraph G;
sjcount(G,10);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -