输入字符串按照ansi码表排序(考虑字母重复)

来源:互联网 发布:做淘宝运营好吗 编辑:程序博客网 时间:2024/05/08 22:57
#include <iostream>#include <string.h>#include <stdio.h>using namespace std;void my_sort(char *a){int len = strlen(a);int temp = 0;for (int i = 0; i < len; ++i) {for (int j = i + 1; j < len; ++j) {if (a[i] > a[j]) {temp = a[i];a[i] = a[j];a[j] = temp;}}}}int main(){cout << "input T:";int T;cin >> T;char **p = new char *[T];for (int i = 0; i <= T; ++i) {*(p + i) = new char[100];gets(*(p + i));my_sort(*(p + i));}for (int j = 0; j <= T; ++j) {cout << *(p + j) << endl;}return 0;}


0 0
原创粉丝点击