justinpuckett

Untitled

May 27th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. bool isSorted(int[], int);
  6.  
  7. int main()
  8. {
  9.     cout << " Enter list: ";
  10.     int size;
  11.     cin >> size;
  12.     int number[size];
  13.  
  14.     for (int i = 0; i < size; i++)
  15.     {
  16.         cin >> number[i];
  17.     }
  18.  
  19.     if (isSorted(number[] , size))
  20.         cout << " The list is already sorted \n" << endl;
  21.     else
  22.         cout << " The list is not sorted \n" << endl;
  23.  
  24.     return 0;
  25. }
  26.  
  27. bool isSorted(int number[], int size)
  28. {
  29.     for (int i = 0; i < size; i++)
  30.     {
  31.         if (number[i] > number[i + 1])
  32.             return false;
  33.     }
  34.     return true;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment