Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- bool isSorted(const int list[], int size){
- for(int i = 0; i < size-1; i++)
- if(list[i] > list[i+1])
- return false;
- return true;
- }
- int main(){
- const int MAX_LIST_SIZE = 80;
- int list[MAX_LIST_SIZE];
- int size;
- string mystr;
- cout << "Enter list: ";
- getline(cin, mystr);
- stringstream ss(mystr);
- ss >> size;
- for(int initial = 0; initial < size; initial++){
- ss >> list[initial];
- }
- if(isSorted(list, size)) cout << "The list is sorted. << endl;
- else cout << "The list is not sorted. << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement