fork download
  1. #include <iostream>
  2.  
  3. #define SIZE 100000
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. char a[SIZE];
  10. int n, i;
  11.  
  12. cin >> n;
  13.  
  14. for (i = 0; i < n; i++)
  15. cin >> a[i];
  16.  
  17. for (i = 0; i < n - 1; i++)
  18. if (a[i] > a[i + 1])
  19. break;
  20.  
  21. if (i == n - 1)
  22. cout << "Sorted";
  23. else
  24. cout << "Not Sorted";
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3344KB
stdin
8
abcdefga
stdout
Not Sorted