#include <stdio.h> #include<string.h> int main() { char a[100]; int i,j,k,len; gets_s(a); len= strlen(a);/*计数器:遇到' '停止并返回计数器值*/ for(i=0;i<len/2;i++) for(j=0;j<len-2;j+=2) if (a[i] > a[i + 2]) { k = a[i]; a[i] = a[i + 2]; a[i + 2] = k; } for (i = 0; i < len; i++) printf("%3c", a[i]); }