我的代码:
/*
*作者:xuyuanye2013
*完成日期:2013年11月6日
*问题描述:产生一个50X2的矩阵(二维数组),每个元素是0-10的随机数
*算法:
*/
#include"stdio.h"// “standard input & output"(标准输入输出)头文件
#include"stdlib.h"//标准库头文件,含malloc()、calloc()、realloc()、free()
//system()、atoi()、atol()、rand()、srand()、exit()
#include"time.h"//日期和时间头文件,含time()
#define M 50 //数组行
#define N 2 //数组列
int main()
{
int a[M][N];//定义M行N列二维数组
srand((int)time(NULL));//srand函数是随机数发生器的初始化函数
printf("随机产生50个二维数组:\n");
for (int = 0; rx < M; rx++)
for (int lx = 0; lx < N; lx++)
a[rx][lx] = rand()/3276;
for (rx = 0; rx < M; rx++)
printf("(%d %d)\t", a[rx][0],a[rx][1]);
printf("\n");
system("pause");
return 0;
}
运行结果: