guitar-player

ordena

Nov 15th, 2011
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include<iostream>
  2. //#include
  3. using namespace std;
  4.  
  5. inline void intercambio(tipoElemento Aa[], int i, int j)
  6.   { tipoElemento t = a[i]; a[i] = a[j]; a[j] = t;}
  7.  
  8. ordenar3(tipoElemento a[], int N)
  9.   {
  10.    if (a[1] > a[2]) intercambio(a, 1, 2);
  11.    if (a[1] > a[3]) intercambio(a, 1, 3);
  12.    if (a[2] > a[3]) intercambio(a, 2, 3);
  13.   }
  14.  
  15. const int maxN = 100;
  16.  
  17. int main()
  18. {
  19.  int N, i;
  20.  tipoElemento v, a[maxN+1];
  21.  
  22.  N = 0;
  23.  while (cin >> v) a[++N] = v;
  24.  a[0] = 0;
  25.  ordenar3(a, N);
  26.  for (i = 1; i<= N; i++) cout << a[i] << ' ' << endl;
  27.  
  28.  
  29.  return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment