C语言,随机生成矩阵
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/06 11:58:58
C语言,随机生成矩阵
#include
#include
void RAND_RECTANGE(int x);
int main(void){
int x ;
srand(time(0));
x = rand() % 10;
RAND_RECTANGE(x);
}
void RAND_RECTANGE(int x){
int num[x][x] ;
int a,b;
for( a = 0 ; a < x; a++){
for( b = 0 ; b < x;b++){
num[a][b] = rand() % 100;
}
}
or( a = 0 ; a < x; a++){
for( b = 0 ; b < x;b++){
printf("num[%d][%d] = %d ,a,b,num[a][b];
}
printf("\n");
}
}
#include
void RAND_RECTANGE(int x);
int main(void){
int x ;
srand(time(0));
x = rand() % 10;
RAND_RECTANGE(x);
}
void RAND_RECTANGE(int x){
int num[x][x] ;
int a,b;
for( a = 0 ; a < x; a++){
for( b = 0 ; b < x;b++){
num[a][b] = rand() % 100;
}
}
or( a = 0 ; a < x; a++){
for( b = 0 ; b < x;b++){
printf("num[%d][%d] = %d ,a,b,num[a][b];
}
printf("\n");
}
}