【发布时间】:2014-03-06 04:02:06
【问题描述】:
我明天有一个项目要上 C 课,其中一部分是创建一个用户定义的矩阵。用户将输入矩阵有多少行和多少列,以及矩阵内的最小和最大数字。这些数字在用户定义的数字之间是随机的。输入所有内容后,应该显示矩阵。
它编译并运行,但除了显示一个随机数之外什么都不做。
这是我目前所拥有的:
float GetUserInfo(){ //getting the user to define the size and values of the matrix
int nrows, ncol, min, max;
int matrix[50][50],i, j;
printf("Please enter the number of rows and columns for the matrix:\n");
printf("number of rows: ");
scanf("%d", &nrows);
printf("number of columns: ");
scanf("%d", &ncol);
printf("Now enter the min and max value:\n");
printf("min value: ");
scanf("%d", &min);
printf("max value: ");
scanf("%d", &max);
for(i=0;i<nrows;i++){
for(j=0;j<ncol;j++){
}
}
matrix[i][j]=rand();
printf("The matrix generated is:\n%d \t", matrix[i][j]);
return;
}
【问题讨论】:
标签: c