SHOW:
|
|
- or go back to the newest paste.
| 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 number[80]; | |
| 11 | cin >> number[0]; | |
| 12 | - | int size = number[0]; |
| 12 | + | int size = number[0];/* not needed */ |
| 13 | ||
| 14 | for (int i = 1; i < size; i++) | |
| 15 | {
| |
| 16 | cin >> number[i]; | |
| 17 | } | |
| 18 | ||
| 19 | - | if (isSorted(int[] , int) |
| 19 | + | if (isSorted(int[] , int)/* something isn't right here should be passing names */ |
| 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 = 1; i < size-1; i++) | |
| 30 | {
| |
| 31 | - | if (number[i] > number[i + 1]) |
| 31 | + | cout << "i: " << i << " number[i]: " << number[i] << " number[i + 1]: " << number[i + 1] << endl; |
| 32 | - | return false; |
| 32 | + | if (number[i] > number[i + 1]) |
| 33 | return false; | |
| 34 | - | return true; |
| 34 | + | } |
| 35 | return true; | |
| 36 | } |