难题 求高手帮忙
定义以下6*6阶方阵,并按以下数据进行初始化,编一程序,按12345678.。。。顺序输出数据。int a[6][6]=
{1, 2, 6, 7,15,16,
3, 5, 8,14,17,26,
4, 9,13,18,25,27,
10,12,19,24,28,33,
11,20,23,29,32,34,
21,22,30,31,35,36
};
----------------解决方案--------------------------------------------------------
就是将数组中的数据从小到大输出,冒泡排序......
----------------解决方案--------------------------------------------------------
学习了
刚到二维数组 ----------------解决方案--------------------------------------------------------
回复 2# 的帖子
不是不是 你斜着看 是按斜着的那个规律输出的 ----------------解决方案--------------------------------------------------------
#include <stdio.h>
int main()
{
int a[6][6]={1, 2, 6, 7,15,16,3, 5, 8,14,17,26,4, 9,13,18,25,27,10,12,19,24,28,33,11,20,23,29,32,34,21,22,30,31,35,36};
int max=0;
for(int i=0;i<6;i++)
for(int j=0;j<6;j++)
if(a[i][j]>max)
max=a[i][j];
int *b=new int[max];
for( i=0;i<max;i++)
b[i]=0;
for( i=0;i<max;i++)
b[a[i/6][i%6]]++;
for(int j=0;j<max;j++)
while(b[j]-->0)
printf("%d ",j);
return 0;
}
----------------解决方案--------------------------------------------------------
怎么像不对啊!!
----------------解决方案--------------------------------------------------------
你真的弄懂了吗?用c++编译..不要tc
----------------解决方案--------------------------------------------------------
回复 5# 的帖子
--------------------Configuration: m - Win32 Debug--------------------Compiling...
m.c
c:\documents and settings\administrator\m.c(7) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\m.c(7) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\m.c(7) : error C2143: syntax error : missing ')' before 'type'
c:\documents and settings\administrator\m.c(7) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\m.c(7) : error C2065: 'i' : undeclared identifier
c:\documents and settings\administrator\m.c(7) : warning C4552: '<' : operator has no effect; expected operator with side-effect
c:\documents and settings\administrator\m.c(7) : error C2059: syntax error : ')'
c:\documents and settings\administrator\m.c(8) : error C2143: syntax error : missing ';' before 'for'
c:\documents and settings\administrator\m.c(8) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\m.c(8) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\m.c(8) : error C2143: syntax error : missing ')' before 'type'
c:\documents and settings\administrator\m.c(8) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\m.c(8) : error C2065: 'j' : undeclared identifier
c:\documents and settings\administrator\m.c(8) : warning C4552: '<' : operator has no effect; expected operator with side-effect
c:\documents and settings\administrator\m.c(8) : error C2059: syntax error : ')'
c:\documents and settings\administrator\m.c(9) : error C2143: syntax error : missing ';' before 'if'
c:\documents and settings\administrator\m.c(12) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\m.c(14) : error C2065: 'b' : undeclared identifier
c:\documents and settings\administrator\m.c(14) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\m.c(14) : error C2106: '=' : left operand must be l-value
c:\documents and settings\administrator\m.c(17) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\m.c(17) : error C2105: '++' needs l-value
c:\documents and settings\administrator\m.c(19) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\m.c(19) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\m.c(19) : error C2143: syntax error : missing ')' before 'type'
c:\documents and settings\administrator\m.c(19) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\m.c(19) : warning C4552: '<' : operator has no effect; expected operator with side-effect
c:\documents and settings\administrator\m.c(19) : error C2059: syntax error : ')'
c:\documents and settings\administrator\m.c(20) : error C2143: syntax error : missing ';' before 'while'
c:\documents and settings\administrator\m.c(20) : error C2109: subscript requires array or pointer type
c:\documents and settings\administrator\m.c(20) : error C2105: '--' needs l-value
Error executing cl.exe.
m.obj - 28 error(s), 3 warning(s)
----------------解决方案--------------------------------------------------------
文件扩展名字改成.cpp
----------------解决方案--------------------------------------------------------
回复 9# 的帖子
我qq308612639 我还有东西想问你一下 ----------------解决方案--------------------------------------------------------