I see what you did there. Might work if I inputted directly to the array and then just moved to the left until it hit a number lower than itself.
edit: It works now! And the code got a little shorter:
Code:
#include <iostream.h>
#define ANTAL 9
int main()
{
int tal[ANTAL + 1], i;
for (i = 0; i <= ANTAL; i++) {
cout << "Skriv ett tal: ";
cin >> tal[i];
for (int z = i; z; z--)
if (tal[z - 1] > tal[z]) {
int temp = tal[z - 1];
tal [z - 1] = tal[z];
tal[z] = temp;
}
else
break;
}
for (i = 0; i <= ANTAL; i++)
cout << tal[i] << " ";
return 0;
}