Sorting within a string (question 5 of the Jiudu Tutorial)

insert image description here

#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdio.h>
using namespace std;
int main()
{
    
    
    char a[101];
    while(gets(a))
    {
    
    
        int len=strlen(a);
        if(len==0)
            break;
        sort(a,a+len);
        puts(a);
    }
    return 0;
}

The C library function int puts(const char *str) writes a string to stdout up to but not including a null character. Newline characters are appended to the output.

Guess you like

Origin blog.csdn.net/weixin_44022810/article/details/106822680