Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- void bub(char* s){
- int i, j, n=strlen(s);
- char tmp;
- char st[n];
- strcpy(st,s);
- for(i=n-1;i>0;i--){
- for(j=0;j<i;j++){
- if(st[j]>st[j+1]){
- tmp=st[j];
- st[j]=st[j+1];
- st[j+1]=tmp;
- }
- }
- }
- printf("%s\n", st);
- }
- int main(){
- int n;
- printf("введите размер массива\n");
- scanf("%i", &n);
- char* str=malloc(sizeof (n));
- printf("введите массив символов меньший или равный %i\n", n-1);
- fgets(str,n-1,stdin);
- int i;
- printf("%s\n", str);
- bub(str);
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement