BCSAPXEP


SUBMITTED BY: Guest

DATE: Feb. 16, 2014, 9:51 a.m.

FORMAT: C++

SIZE: 928 Bytes

HITS: 973

  1. //Haha TTpro
  2. //BCSAPXEP
  3. //http://www.spoj.com/PTIT/problems/BCSAPXEP/
  4. #include <iostream>
  5. using namespace std;
  6. void doicho(int &a, int &b);
  7. void input(int &n, int a[]);
  8. void soft(int &n,int a[]);
  9. void output(int &n, int a[]);
  10. int main()
  11. {
  12. int n;
  13. int a[1000];
  14. input(n,a);
  15. soft(n,a);
  16. output(n,a);
  17. }
  18. void input(int &n, int a[])
  19. {
  20. int i;
  21. cin >>n;
  22. for (i=0;i<n;i++)
  23. {
  24. cin >> a[i];
  25. }
  26. }
  27. void soft(int &n,int a[])
  28. {
  29. int i,j;
  30. for (i=0;i<n;i++)
  31. for (j=i+1;j<n;j++)
  32. {
  33. if (a[i]>a[j]) doicho(a[i],a[j]);
  34. }
  35. }
  36. void doicho(int &a, int &b)
  37. {
  38. int c;
  39. c=a;
  40. a=b;
  41. b=c;
  42. }
  43. void output(int &n, int a[])
  44. {int i;
  45. for (i=0;i<n;i++)
  46. {
  47. cout<< a[i]<<endl;
  48. }
  49. }

comments powered by Disqus