Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ËÀÁÎÐÀÒÎÐÍÀß ÐÀÁÎÒÀ ¹ 9.1
- ÂÀÐÈÀÍÒ 20
- ÂÛÏÎËÍÈË: ÄÌÈÒÐÈÉ ÌÈØÓÒÈÍ ÊÝ - 101
- */
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- using namespace std;
- void my_swap(char &a, char &b){
- char tmp = a;
- a = b;
- b = tmp;
- }
- void sort_str(char * str){
- int n = strlen(str);
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n - i - 1; j++){
- if(str[j] != ' ' && str[j + 1] != ' ' && str[j] > str[j + 1]){
- my_swap(str[j], str[j + 1]);
- }
- }
- }
- }
- void scan_str(char * str){
- int i = 0;
- char ch = '\0';
- while(true){
- scanf("%c", &ch);
- if(ch == '\n'){
- break;
- }
- str[i] = ch;
- i++;
- }
- }
- int main(){
- char * str = (char *) malloc(100 * sizeof(char));
- scan_str(str);
- sort_str(str);
- printf("%s", str);
- free(str);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement