标签:c style class blog code java
#include <iostream> using namespace std; void mSort(int *arr, int iLen) { int i, j, k, tmp; for(i = 0, j = 0; i < iLen; i++) { if (arr[i] < 0) { tmp = arr[i]; for(k = i; k > j; k--) arr[k] = arr[k - 1]; arr[j++] = tmp; } } } int main() { int arr[] = {1,7,-5,9,-12,15}; // int iLen = sizeof(arr) / sizeof(int); int i; int iLen = 6; cout<<"输入"<<iLen<<"个数"<<endl; for(i = 0; i < iLen; i++) cin>>arr[i]; cout << "排序前数组为: " << endl; for(i = 0; i < iLen; i++) cout << arr[i] << " "; cout << endl mSort(arr, iLen); cout << "排序后数组为: " << endl; for(i = 0; i < iLen; i++) cout << arr[i] << " "; cout << endl // system("PAUSE"); return 0; }
标签:c style class blog code java
原文地址:http://www.cnblogs.com/Xilian/p/3765376.html