70,037
社区成员
发帖
与我相关
我的任务
分享
int *temp;
int m,n;
scanf("%d%d",&m,&n);
temp=(int *)malloc(m*n*sizeof(int));
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
scanf("%d",&a[i][j]);
#include<iostream>
#include <cstdlib>
using namespace std;
int main()
{
int *temp;
int m,n;
printf("Input the m,n:");
scanf("%d%d",&m,&n);
temp=(int *)malloc(m*n*sizeof(int));
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
{
printf("Input the data: ");
scanf("%d", &temp[i,j]); //好象直接这样子就可以的,
}
for (int i=0; i<m; i++)
for(int j=0; j<n; j++)
printf("%d ", temp[i,j]);
return 0;
}
int *temp;
const int n=3; //一维数组长度已知
int m;
int (*a)[n]; //指向数组的指针
scanf("%d",&m);
temp=(int *)malloc(m*n*sizeof(int));
a = (int(*)[n])temp;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
scanf("%d",&a[i][j]);
}
free(temp);
int *temp;
int m,n;
int **a;
scanf("%d%d",&m,&n);
a = (int **)malloc(m*sizeof(int *));
temp=(int *)malloc(m*n*sizeof(int));
for(int i=0;i<m;i++)
{
a[i] = temp+n;
for(int j=0;j<n;j++)
scanf("%d",&a[i][j]);
}
//...
free(a);
free(temp);
int *temp;
int m,n;
scanf("%d%d",&m,&n);
temp=(int *)malloc(m*n*sizeof(int));
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
scanf("%d",(tempa+i*m+j));
int *temp;
int m,n;
scanf("%d%d",&m,&n);
temp=(int *)malloc(m*n*sizeof(int));
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
scanf("%d", &tmp[i*m+j]);