I have a problem with how to sort the descendant of this 5th array on this line of code. Can anyone explain how it works?
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;
void main() { float a[5] , k; int i,j ;
for(i=0 ; i<5; i++) cin>> a[i];
=====================these lines============================
for(i=0;i<4;i++)
for(j=i+1;j<5;j++)
if (a[i]<a[j])
{
k=a[i];
a[i]=a[j];
a[j]=k;
}
=================================================
for (i=0; i<5;i++) cout << " "<<a[i];
_getch();
}
Aucun commentaire:
Enregistrer un commentaire