[ create a new paste ] login | about

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

C++, pasted on Jun 11:
#include <iostream>
using namespace std;

int main()
{
  static int a[] = { 31, 41, 59, 26, 53, 58, 97, 93, 23, 84, 62 };
  int flag;
  do {
    flag = 0;    
    for (int i = 0; i < sizeof(a)/sizeof(a[0]) - 1; i++) {
      if (a[i] > a[i + 1]) {
        swap(a[i], a[i + 1]);
        flag = 1;
      }
    }
  } while (flag > 0);

  for (int i = 0; i < sizeof(a)/sizeof(a[0]); i++)
    cout << a[i] << ", ";
  cout << endl;
  return 0;
}
/* end */


Output:
1
2
3
4
cc1plus: warnings being treated as errors
In function 'int main()':
Line 10: warning: comparison between signed and unsigned integer expressions
Line 18: warning: comparison between signed and unsigned integer expressions


Create a new paste based on this one


Comments: