| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 646 人关注过本帖
标题:请求帮助啊,二维数组的问题、谢谢啊!
只看楼主 加入收藏
zhaoqiang053
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2006-5-17
收藏
 问题点数:0 回复次数:5 
请求帮助啊,二维数组的问题、谢谢啊!

帮我看看这个程序
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int trsmat(int a[][5])
{int b[5][1];
int i;
int j;
for(i=0;i<1;i++)
for(j=0;j<5;j++)
b[j][i]=a[i][j];
return b;
}
int addmat(int a[][5],int b[][5])
{int c[1][5];
int i;
int j;
for(i=0;i<1;i++)
for(j=0;j<5;j++)
c[i][j]=a[i][j]+b[i][j];
return c;
}
int mutmat(int At[5][1],int Y[1][5])
{int m;
int i;
int j;
m=0;
for(i=0;i<1;i++)
for(j=0;j<5;j++)
m=m+At[i][j]*Y[i][j];
return m;
}
int Exmat(int a[1][4])
{int b[1][5];
int i;
int j;

for(i=0;i<1;i++)
for(j=0;j<5;j++)
b[i][j+1]=a[i][j];
b[0][0]=1;
return b;
}
main()
{int a[100];
int b[100];
int A[1][4];
int B[1][4];
int ExA[1][5];
int ExB[1][5];
int Aflag;
int Bflag;
Aflag=1;
Bflag=0;
int A1[1][5]={0,0,0,0,0};
int At[5][1];
int i;
int j;
for(i=0;i<100;i++)
{a[i]=random();
b[i]=random();
}
printf("已经随机产生了200个数,分为两类后它们分别是\n");
printf("A类为\n");
for(i=0;i<100;i++)
printf("%d",a[i]);
printf("B类为\n");
for(i=0;i<100;i++)
printf("%d",b[i]);
printf("抽样\n");
for(i=0;i<1;i++)
for(j=0;j<4;j++)
{A[i][j]=a[j];
B[i][j]=b[j];
}
printf("采样样本变换成增广矩阵\n");
ExA=Exmat(A[1][4]);
ExB=Exmat(B[1][4]);
while(Aflag!=1||Bflag!=0)
{int k;
k=1;
printf("第%d步\n",k);
printf("计算A的转置\n");
At=trsmat(A1[1][5]);
printf("下面计算AT*Y\n");
Aflag=mutmat(At[5][1],ExA[1][5]);
if(Aflag<0)
{Aflag=0;
A1[1][5]=addmat(A1[1][5],ExA[1][5]);
}
At=trsmat(A1[1][5]);
Bflag=mutmat(At[5][1],ExB[1][5]);
if(Bflag>0)
{Bflag=1;
A1[1][5]=addmat(A1[1][5],ExB[1][5]);
}
k++;

}
printf("经过递推A为;\n");
for(i=0;i<1;i++)
for(j=0;j<5;j++)
printf("%d",A1[i][j]);
printf("所得递推公式为:\n");
printf("y=%dx1+%dx2+%dx3+%dx4+%dx5",A1[0][0],A1[0][1],A1[2][3],A1[0][4]);


}
错误为:
--------------------Configuration: zhaoqiang - Win32 Debug--------------------
Compiling...
zhaoqiang.c
c:\documents and settings\administrator\桌面\zhaoqiang.c(11) : warning C4047: 'return' : 'int ' differs in levels of indirection from 'int [5][1]'
c:\documents and settings\administrator\桌面\zhaoqiang.c(11) : warning C4172: returning address of local variable or temporary
c:\documents and settings\administrator\桌面\zhaoqiang.c(20) : warning C4047: 'return' : 'int ' differs in levels of indirection from 'int [1][5]'
c:\documents and settings\administrator\桌面\zhaoqiang.c(20) : warning C4172: returning address of local variable or temporary
c:\documents and settings\administrator\桌面\zhaoqiang.c(41) : warning C4047: 'return' : 'int ' differs in levels of indirection from 'int [1][5]'
c:\documents and settings\administrator\桌面\zhaoqiang.c(41) : warning C4172: returning address of local variable or temporary
c:\documents and settings\administrator\桌面\zhaoqiang.c(54) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\桌面\zhaoqiang.c(55) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\桌面\zhaoqiang.c(56) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\桌面\zhaoqiang.c(57) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\桌面\zhaoqiang.c(58) : error C2065: 'i' : undeclared identifier
c:\documents and settings\administrator\桌面\zhaoqiang.c(59) : warning C4013: 'random' undefined; assuming extern returning int
c:\documents and settings\administrator\桌面\zhaoqiang.c(71) : error C2065: 'j' : undeclared identifier
c:\documents and settings\administrator\桌面\zhaoqiang.c(76) : warning C4047: 'function' : 'int (*)[4]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(76) : warning C4024: 'Exmat' : different types for formal and actual parameter 1
c:\documents and settings\administrator\桌面\zhaoqiang.c(76) : warning C4047: '=' : 'int [1][5]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(76) : error C2106: '=' : left operand must be l-value
c:\documents and settings\administrator\桌面\zhaoqiang.c(77) : warning C4047: 'function' : 'int (*)[4]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(77) : warning C4024: 'Exmat' : different types for formal and actual parameter 1
c:\documents and settings\administrator\桌面\zhaoqiang.c(77) : warning C4047: '=' : 'int [1][5]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(77) : error C2106: '=' : left operand must be l-value
c:\documents and settings\administrator\桌面\zhaoqiang.c(83) : error C2065: 'At' : undeclared identifier
c:\documents and settings\administrator\桌面\zhaoqiang.c(83) : error C2065: 'A1' : undeclared identifier
c:\documents and settings\administrator\桌面\zhaoqiang.c(83) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(83) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(83) : warning C4047: 'function' : 'int (*)[5]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(83) : warning C4024: 'trsmat' : different types for formal and actual parameter 1
c:\documents and settings\administrator\桌面\zhaoqiang.c(85) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(85) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(85) : warning C4047: 'function' : 'int (*)[1]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(85) : warning C4024: 'mutmat' : different types for formal and actual parameter 1
c:\documents and settings\administrator\桌面\zhaoqiang.c(85) : warning C4047: 'function' : 'int (*)[5]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(85) : warning C4024: 'mutmat' : different types for formal and actual parameter 2
c:\documents and settings\administrator\桌面\zhaoqiang.c(88) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(88) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(88) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(88) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(88) : warning C4047: 'function' : 'int (*)[5]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(88) : warning C4024: 'addmat' : different types for formal and actual parameter 1
c:\documents and settings\administrator\桌面\zhaoqiang.c(88) : warning C4047: 'function' : 'int (*)[5]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(88) : warning C4024: 'addmat' : different types for formal and actual parameter 2
c:\documents and settings\administrator\桌面\zhaoqiang.c(88) : error C2106: '=' : left operand must be l-value
c:\documents and settings\administrator\桌面\zhaoqiang.c(90) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(90) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(90) : warning C4047: 'function' : 'int (*)[5]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(90) : warning C4024: 'trsmat' : different types for formal and actual parameter 1
c:\documents and settings\administrator\桌面\zhaoqiang.c(91) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(91) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(91) : warning C4047: 'function' : 'int (*)[1]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(91) : warning C4024: 'mutmat' : different types for formal and actual parameter 1
c:\documents and settings\administrator\桌面\zhaoqiang.c(91) : warning C4047: 'function' : 'int (*)[5]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(91) : warning C4024: 'mutmat' : different types for formal and actual parameter 2
c:\documents and settings\administrator\桌面\zhaoqiang.c(94) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(94) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(94) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(94) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(94) : warning C4047: 'function' : 'int (*)[5]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(94) : warning C4024: 'addmat' : different types for formal and actual parameter 1
c:\documents and settings\administrator\桌面\zhaoqiang.c(94) : warning C4047: 'function' : 'int (*)[5]' differs in levels of indirection from 'int '
c:\documents and settings\administrator\桌面\zhaoqiang.c(94) : warning C4024: 'addmat' : different types for formal and actual parameter 2
c:\documents and settings\administrator\桌面\zhaoqiang.c(94) : error C2106: '=' : left operand must be l-value
c:\documents and settings\administrator\桌面\zhaoqiang.c(102) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(102) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(104) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(104) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(104) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(104) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(104) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(104) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(104) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\桌面\zhaoqiang.c(104) : error C2109: subscript requires array or pointer type
执行 cl.exe 时出错.

zhaoqiang.obj - 1 error(s), 0 warning(s)

搜索更多相关主题的帖子: 请求 
2006-05-19 18:35
独角龙
Rank: 1
等 级:新手上路
帖 子:221
专家分:0
注 册:2006-5-5
收藏
得分:0 

奋斗改变一切!!
2006-05-19 18:42
zhaoqiang053
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2006-5-17
收藏
得分:0 
高手们给看看这个程序好吗&gt;谢谢!

努力编程!
2006-05-19 18:42
zhaoqiang053
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2006-5-17
收藏
得分:0 
论坛游民 给看看怎么 样?

努力编程!
2006-05-19 18:43
zhaoqiang053
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2006-5-17
收藏
得分:0 

努力编程!
2006-05-19 18:43
独角龙
Rank: 1
等 级:新手上路
帖 子:221
专家分:0
注 册:2006-5-5
收藏
得分:0 

random 方法

返回介于 0 和 1 之间的伪随机数。

????

一个错误:
D:\Text1.c(65) : warning C4013: 'random' undefined; assuming extern returning int

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int trsmat(int a[][5])
{
int b[5][1];
int i;
int j;
for(i=0;i<1;i++)
for(j=0;j<5;j++)
b[j][i]=a[i][j];
return b[5][1];
}
int addmat(int a[][5],int b[][5])
{
int c[1][5];
int i;
int j;
for(i=0;i<1;i++)
for(j=0;j<5;j++)
c[i][j]=a[i][j]+b[i][j];
return c[5][1];
}
int mutmat(int At[5][1],int Y[1][5])
{
int m;
int i;
int j;
m=0;
for(i=0;i<1;i++)
for(j=0;j<5;j++)
m=m+At[i][j]*Y[i][j];
return m;
}
int Exmat(int a[1][4])
{
int b[1][5];
int i;
int j;
for(i=0;i<1;i++)
for(j=0;j<5;j++)
b[i][j+1]=a[i][j];
b[0][0]=1;
return b[1][5];
}
main()
{
int a[100];
int b[100];
int A[1][4];
int B[1][4];
int ExA[1][5];
int ExB[1][5];
int Aflag;
int Bflag;
int A1[1][5]={0,0,0,0,0};
int At[5][1];
int i, j;
Aflag=1;
Bflag=0;

for(i=0;i<100;i++)
{
a[i]=random();
b[i]=random();

}
printf("已经随机产生了200个数,分为两类后它们分别是\n");
printf("A类为\n");
for(i=0;i<100;i++)
printf("%d",a[i]);
printf("B类为\n");
for(i=0;i<100;i++)
printf("%d",b[i]);
printf("抽样\n");
for(i=0;i<1;i++)
for(j=0;j<4;j++)
{
A[i][j]=a[j];
B[i][j]=b[j];
}
printf("采样样本变换成增广矩阵\n");
ExA[1][5]=Exmat(A);
ExB[1][5]=Exmat(B);
while(Aflag!=1||Bflag!=0)
{
int k;
k=1;
printf("第%d步\n",k);
printf("计算A的转置\n");
At[5][1] = trsmat(A1);
printf("下面计算AT*Y\n");
Aflag=mutmat(At,ExA);
if(Aflag<0)
{
Aflag=0;
A1[1][5]=addmat(A1,ExA);
}
At[5][1]=trsmat(A1);
Bflag=mutmat(At,ExB);
if(Bflag>0)
{
Bflag=1;
A1[1][5]=addmat(A1,ExB);
}
k++;
}
printf("经过递推A为;\n");
for(i=0;i<1;i++)
for(j=0;j<5;j++)
printf("%d",A1[i][j]);
printf("所得递推公式为:\n");
printf("y=%dx1+%dx2+%dx3+%dx4+%dx5",A1[0][0],A1[0][1],A1[2][3],A1[0][4]);


}


奋斗改变一切!!
2006-05-20 09:32
快速回复:请求帮助啊,二维数组的问题、谢谢啊!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048709 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved