Skip to content

Instantly share code, notes, and snippets.

@kaecy
Created December 5, 2013 13:20
Show Gist options
  • Select an option

  • Save kaecy/7805024 to your computer and use it in GitHub Desktop.

Select an option

Save kaecy/7805024 to your computer and use it in GitHub Desktop.
/* use: asc <numbers...>
asc is short for ascending
out: "sort" || "not sorted" */
#include <iostream>
#include <cstdlib>
int main(int argc, char **argv) {
for (short a = 0; a < (argc - 1); ++ a)
{
if (! (atoi(argv[a]) <= atoi(argv[a+1])) ) {
std::cout << "not sorted" << std::endl;
return 1;
}
}
std::cout << "sorted" << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment