标签:c/c++
//--------------------------------------------------------------------------- #pragma hdrstop //--------------------------------------------------------------------------- #pragma argsused #include <iostream> #include <stdio.h> using namespace std; int data[]={2,8,7,6,9,1,5,0}; int main(int argc, char* argv[]) { int length = sizeof(data)/sizeof(int); int i=0; while(i < length-1) { int j =0; while(j < length-1-i) { if(data[j] > data[j+1]) { int temp = data[j]; data[j] = data[j+1]; data[j+1]= temp; } ++j; } ++i; } for(int i=0;i<length;i++) { cout << data[i] << endl; } getchar(); return 0; } //---------------------------------------------------------------------------
标签:c/c++
原文地址:http://9233403.blog.51cto.com/9223403/1967260