#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int array[] = {8,9,5,7,6};
for(int i =0;i<5;i++){
int j = i + 1;
if (j > 4){
break;
}
int tag = array[j];
while(j > 0 && array[j-1] > tag){
array[j] = array[j-1] ;
j--;
}
array[j] = tag;
}
for(int i =0;i<5;i++){
cout << array[i] << endl;
}
return 0;
}
沒有留言:
張貼留言