(Arithmetic exercises) - within string sorting

Requirements:
http://codeup.cn/problem.php?cid=100000581&pid=3
Description:
This problem is relatively simple, but the subject did not say understand - if there is space, whether the space to participate output it? He wrote the first space instead of being given to how == input on how the output is actually the middle on it with a sort
of code:

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

char str[210];
int main(){
	int signal = 0;
	int len;
	while(gets(str)){
		len = strlen(str);
		sort(str,str+len);
		
		for(int i = 0;i <len;i++){
			//判断一个字符是否是空格,见下,并不是" ",也不用strcmp——这是比较字符串是否相等的 
			/*
			if(str[i] == ' '){
				printf("");
			}
			else{
				printf("%c",str[i]);
			}
			*/
			printf("%c",str[i]);	
		}
		printf("\n");
	}
}
Published 105 original articles · won praise 3 · Views 1972

Guess you like

Origin blog.csdn.net/weixin_42377217/article/details/103971812