
作业社区
探索学习新天地,共享知识资源!
慕先生4541263 的学生作业:
#include void output_array(char *p, int len) { for (int i = 0; i < len; i++) { printf("%c ", p[i]); } printf("\n"); } void choice_sort(char *p, int len) { for (int i = 0; i < len - 1; i++) { int k = i; for (int j = i + 1; j < len; j++) { if (p[k] > p[j]) { k = j; } } if (k != i) { p[i] ^= p[k]; p[k] ^= p[i]; p[i] ^= p[k]; } } } int main() { unsigned char str[] = "decba"; output_array(str, strlen(str)); choice_sort(str, strlen(str)); output_array(str, strlen(str)); return 0; }




