「C言語入門」バブルソート(単純交換ソート)のサンプルコード

参考ソースコード:
void pointArr(){
int arr[] = {5,4,6,2,8,1,3};
int count = sizeof(arr)/sizeof(arr[0]);

int *pointer;
pointer = arr;
for (int i = 0; i<count-1; i++) {
for (int j = 0; j<count-i-1; j++) {
if (*(pointer+j)<*(pointer+j+1)) {
int tem;
tem = *(pointer+j);
*(pointer+j) = *(pointer+j+1);
*(pointer+j+1) = tem;
}
}
}

for (int x = 0; x<count; x++) {

printf(“count=%i,value=%i\n",count,arr[x]);

}

}

C++

Posted by arkgame