用c语言指针实现给整形数组冒泡排序

来源:互联网 发布:mac顶部菜单栏固定 编辑:程序博客网 时间:2024/04/29 06:32
#include<stdio.h>void reverse(const int *start,const int *end){int *tstart = start;while (start != end){int *left = tstart;while (left != end){if (*left > *(left + 1)){*left = *left^*(left + 1);*(left + 1) = *left^*(left + 1);*left = *left ^ *(left + 1);left++;}elseleft++;}start++;}}int main(){int a[] = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };int len = sizeof(a) / sizeof(a[0]);reverse(a, a + len - 1);system("pause");return 0;}


0 0
原创粉丝点击