[ create a new paste ] login | about

Link: http://codepad.org/mgl1BcvL    [ raw code | output | fork ]

C++, pasted on May 15:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;
int main() {
  int a[] = {34, 3, 11, 28, 17};
  unsigned int i, j;
  for (i = 0; i < sizeof(a) / sizeof(int) - 1; i++)
    for (j = 0; j < sizeof(a) / sizeof(int) - 1 - i; j++)
      if (a[j] > a[j + 1])
        swap(a[j], a[j + 1]);
  for (i = 0; i < sizeof(a) / sizeof(int); i++)
    cout << a[i] << ", ";
  cout << endl;
  return 0;
}
/* end */


Output:
1
3, 11, 17, 28, 34, 


Create a new paste based on this one


Comments: