[英]How to sort an 2D array in a descending way
How can i sort an 2D array in a descending way, without using pointers im still a beginner. 我如何以降序方式对2D数组进行排序,而又不使用仍是初学者的指针。
Fore example if i input an 2D array 2x2. 例如,如果我输入一个2D数组2x2。 With the following elements: 2 3 1 5 The output should be: 5 3 2 1
具有以下元素:2 3 1 5输出应为:5 3 2 1
for(i=0;i<row;i++)
for(j=0;j<col;j++)
for(k=0;k<row;k++)
for(p=0;p<col;p++)
if(a[i][j]>a[k][p])
temp=a[i][j]; a[i][j]=a[k][p]; a[k][p]=temp;
This worked for me 这对我有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.