144
for(int i=0;i
for(int j=0;j
cin>>a[j][i];
for(int i=0;i
for(int k=0;k
for(int j=k+1;j
if(a[k][i]>a[j][i]) { t=a[j][i];
a[j][i]=a[k][i];
a[k][i]=t;
}
for(int i=0;i
{
for(int j=0;j
cout<
cout<<‖\n‖; }
return 0;
}
Kiritish uchun ma‘lumot
n=3
3 5 1
0 6 4
8 2 9
Dastur
natijasi
1 3 5
0 4 6
2 8 9
Yuqorida keltirib o‗tilgan algoritm bilan ikki o‗lchovli massiv elementlarini
kamayish tartibida ham saralash mumkin faqatgina sikl ichidagi shartni
almashtirish kerak. Kamayish bo‗yicha tartiblash uchun C++
dasturlash tilida
quyidagi dasturga e‘tibor bering.
#include
using namespace std;
int main()
{ int a[10][10];
int n,t; cout<<‖n=‖;
cin>>n;
for(int i=0;ifor(int j=0;j