大家帮我看看这段代码,究竟哪错了,怎么结果就是不对呢

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
#include<stdio.h><br/>
#include<math.h><br/>
#define MAXSIZE 20 //定义数组的最大长度为20
//定义数组<br/>
int arr1[MAXSIZE][MAXSIZE]; <br/>
int arr2[MAXSIZE][MAXSIZE];
<br/>
void main(){<br/>
int i,j,m;<br/>
printf("please input a algebraic system(such as <N(m),+(m),*(m)>:n"); //告诉用户按照规范格式进行输入,以免出现错误<br/>
scanf("<N(%d),+(%d),*(%d)>",&m,&m,&m); //输入数据
//打印此时的矩阵数组<br/>
printf("运算表值如下:n");<br/>
for(i=0;i<m;i++){<br/>
printf("t%d",i); //按格式输出数组列标<br/>
}<br/>
printf("n");<br/>
for(i=0;i<m;i++){<br/>
printf("%dt",i); //输出数组行标<br/>
for(j=0;j<m;j++){<br/>
if(((i+j)>=m)&&((i*j)>=m)){<br/>
arr1[j]%=m;<br/>
arr2[j]%=m;<br/>
}<br/>
else if(((i+j)<m)&&((i*j)>=m)){<br/>
arr1[j]=i+j;<br/>
arr2[j]%=m;<br/>
}<br/>
else if(((i+j)>=m)&&((i*j)<m)){<br/>
arr1[j]%=m;<br/>
arr2[j]=i*j;<br/>
}<br/>
else{<br/>
arr1[j]=i+j;<br/>
arr2[j]=i*j;<br/>
}<br/>
printf("<%d,%d>t",arr1[j],arr2[j]); //输出数组中进行某种运算后的值<br/>
}<br/>
printf("n");<br/>
}<br/>
printf("由结果可知,该矩阵数组具有对称性");<br/>
<br/>
}

View the full article
 
Back
Top