DrRuckingFetard

Ascending/Descending input

May 27th, 2015
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2.  
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.  
  8. int hold;
  9.  
  10. int array[3];
  11.  
  12. cout<<"Enter 3 numbers: "<<endl;
  13.  
  14. for(int i=0; i<3; i++)
  15.  
  16. {
  17.  
  18. cin>>array[i];
  19.  
  20. }
  21.  
  22. for(int j=0; j<3; j++)
  23.  
  24. {
  25.  
  26.  
  27. }
  28.  
  29. for(int i=0; i<4; i++)
  30.  
  31. {
  32.  
  33. for(int j=0; j<4; j++)
  34.  
  35. {
  36.  
  37. if(array[j]>array[j+1])
  38.  
  39. {
  40.  
  41. hold=array[j];
  42.  
  43. array[j]=array[j+1];
  44.  
  45. array[j+1]=hold;
  46.  
  47. }
  48.  
  49. }
  50.  
  51. }
  52.  
  53. cout<<"Ascending Array is: "<<endl;
  54.  
  55. for(int i=0; i<3; i++)
  56.  
  57. {
  58.  
  59. cout<<array[i]<<endl;
  60.  
  61. }
  62. return 0;
  63. }
Add Comment
Please, Sign In to add comment