Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@achmadweb
Created September 17, 2020 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achmadweb/6c4ba7bdb66857969676af461f84fde6 to your computer and use it in GitHub Desktop.
Save achmadweb/6c4ba7bdb66857969676af461f84fde6 to your computer and use it in GitHub Desktop.
Maximum
#include<stdio.h>
int main()
{
int i;
int Tab[10]= {1, 50, 6, 200, 3, 100, 30, 8, 99, 100 };
int max;
int k, temp;
for (i=0; i<9; i++) {
max=1;
for (k= i+1 ;k< 10; k++) {
if (Tab[k]>Tab[max]) {
max=k;
}
}
temp= Tab[i];
Tab[i]= Tab[max];
Tab[max] = temp;
}
for (i=0; i<10; i++) {
printf (" %d ; ", Tab[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment