二十五岁时我们都一样愚蠢、多愁善感,喜欢故弄玄虚,可如果不那样的话,五十岁时也就不会如此明智。
标题:C示例排序字符串字符的程序
C示例排序字符串字符的程序
#include <stdio.h> #include <string.h> int main (void) { char string[] = "simplyeasylearning"; char temp; int i, j; int n = strlen(string); printf("String before sorting - %s \n", string); for (i = 0; i < n-1; i++) { for (j = i+1; j < n; j++) { if (string[i] > string[j]) { temp = string[i]; string[i] = string[j]; string[j] = temp; } } } printf("String after sorting - %s \n", string); return 0; }