#include <cstdlib> #include <iostream> using namespace std; class sorting{ public: void sort(); private: int a[10]; int b[10][10]; int cur,z,temp,x,y,i; }; void sorting::sort(){ cout<<"Masukan Data: "; cin>>z; for(i=0;i<z;i++) { cout<<"Data ["<<i+1<<"]:"; cin>>a[i]; } for(i=0;i<z;i++) { cur=i; for(int k=i+1;k<z;k++) { if(a[cur]>a[k]) { cur=k; } } temp=a[i]; a[i]=a[cur]; a[cur]=temp; } for(i=0;i<z;i++) { cout<<" "<<a[i]; } cout<<endl; x=0; while(x<1) { y=0; while(y<z) { i=x*z+y; b[x][y]=a[i]; cout<<" "<<b[x][y]; y++; } x++; } } int main(int argc, char *argv[]) { sorting x; x.sort(); cout<<endl; system("PAUSE"); return EXIT_SUCCESS; }
0 Response for the "Array Change + sorting"
Post a Comment