学习型 ASP/PHP/ASP.NET 主机 30元/年全能 ASP/PHP/ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付
 40 1234
发新话题
打印

难题 求高手帮忙

难题 求高手帮忙

定义以下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
};

TOP

就是将数组中的数据从小到大输出,冒泡排序......
雁无留踪之意,水无取影之心

TOP

学习了

刚到二维数组
一上一上又一上   一上上到高山上
举头红日白云低   四海五湖皆一望

TOP

回复 2# 的帖子

不是不是    你斜着看   是按斜着的那个规律输出的

TOP

#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;
}
学习需要安静。。海盗要重新来过。。

TOP

怎么像不对啊!!

TOP

你真的弄懂了吗?用c++编译..不要tc
学习需要安静。。海盗要重新来过。。

TOP

回复 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)

TOP

文件扩展名字改成.cpp
学习需要安静。。海盗要重新来过。。

TOP

回复 9# 的帖子

我qq308612639   我还有东西想问你一下

TOP

 40 1234
发新话题