Untitled

mail@pastecode.io avatar
unknown
plain_text
14 days ago
735 B
1
Indexable
Never
#include <iostream>
using namespace std;

int main(){

    // declare array to store input number
    int array[10];
    int legnth = 10;
    // step1 : input the numbers need to be sorted
    cout<<"please input 10 number"<<endl;
    for(int i=0; i<legnth; i++){
        cin>>array[i];
    }
    cout<<"original array: "<<endl;
    for(int i=0; i<legnth; i++){
        cout<<array[i]<<" ";
    }
    cout<<endl;
    // step2 : implement buble sort
     for(int i=0 ; i<legnth ; i++){
        cout<<array[i]<<" ";
    }
    if(array[j] < array[select idx]){
        select idx = j;
    }
    cout<<"sorted array: "<<endl;
    for(int i=0; i<legnth; i++){
        cout<<array[i]<<" ";
    }
    return 0;
}
Leave a Comment