怎样建立源程(hello.c)我用二维数组有点问题 请指教
你用的是什么开发环境,一般是在文件菜单下,有新建或者添加之类的选项。
你是问怎么建立源程序还是问二维数组的问题呀?
建立源程序一般都是文件>新建>工程>xxx工程。建立好工程里面一般就有一个源文件了。
使用的是IDE么?还是源文件编写?具体的问题可以描述更清楚点么?
《提问的艺术》
http://blog.csdn.net/danky/article/details/1370632
不知道你要问什么 如果是单纯地问二维数组的问题 // c_erweishuzu.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include
#include
#include
int main()
{
int p1;
int **p2;
int **p3;
p1=(int)malloc(sizeof(int*)*2);
for (int i=0;i<2;i++)
{
p1[i]=(int*)malloc(sizeof(int)*3);
}
int j=1;
srand((unsigned)time(NULL));
for (int m=0;m<2;m++)
{
for (int n=0;n<3;n++)
{
p1[m][n]=rand()%10;
printf(" %d",p1[m][n]);
if (j%3==0)
{
printf("\n");
}
j++;
}
}
p2=(int**)malloc(sizeof(int*)*3);
for (int i=0;i<3;i++)
{
p2[i]=(int*)malloc(sizeof(int)*2);
}
for (int m=0;m<3;m++)
{
for (int n=0;n<2;n++)
{
p2[m][n]=rand()%10;
printf(" %d",p2[m][n]);
if (j%2==0)
{
printf("\n");
}
j++;
}
}
p3=(int**)malloc(sizeof(int*)*2);
for (int i=0;i<2;i++)
{
p3[i]=(int*)malloc(sizeof(int)*2);
}
int s=0;
for (int m=0;m<2;m++)
{
for (int n=0;n<2;n++)
{
for (int k=0;k<3;k++)
{
s+=p1[m][k]*p2[k][n];
////printf("%4d",p3[m][n]);
//if (j%2)
//{
// printf("\n");
//}
//j++;
}
p3[m][n]=s;
printf(" %d",p3[m][n]);
if (j%2==0)
{
printf("\n");
}
j++;
}
}
return 0;
}
这个程序希望能帮到你