• 王重阳160809311第9次作业


    #include <stdio.h>
    #include <string.h>
    void aaa()
    {
        char a[100];
        int length,j,i,temp;
        printf("请输入:");
        scanf("%s",a);
        length=strlen(a);
        for(j=0;j<length;j++)
        {
            for(i=1;i<length;i++)
            {
                if(a[i]<a[i-1])
                {
                    temp=a[i];
                    a[i]=a[i-1];
                    a[i-1]=temp;
                }
            }
        }
        printf("将其升序排序为:");
        for(i=0;i<length;i++)
            printf("%c",a[i]);    
    }
    int main()
    {
        aaa();
        return 0;
    }
    #include <stdio.h>
    #include <string.h>
    void aaa()
    {
        char a[100];
        int length,j,i,temp,shell;
        printf("请输入:");
        scanf("%s",a);
        length=strlen(a);
        for(shell= length/2;shell>0;shell/=2)
        {
            for(i=shell;i<length;i++)
            {
                for(j=i-shell;j>=0;j-=shell)
                {
                    if(a[j]>a[j+shell])
                    {
                        temp=a[j];
                        a[j]=a[j+shell];
                        a[j+shell]=temp;
                    }
                }
            }
        }
        printf("将其升序排序为:");
        for(i=0;i<length;i++)
            printf("%c",a[i]);    
    }
    int main()
    {
    
        aaa();
        return 0;
    }
    #include<stdio.h>//判断字符串是否对称 
    #include <string.h>
    int main() 
    {
        char a[100];
        int length,i,j;    
        printf("请输入字符串:
    ");
        scanf("%s",a);
         length=strlen(a);    
        for(i=0,j=length-1;i<=j;j--,i++)
        {
            if(a[i]!=a[j])
            {
                break;
            }        
        }
        if(i>j)
        {
            printf("对称");
        }
        else
        {
            printf("不对称");    
        }
        printf("
    ");
        return 0;        
    }
    #include <stdio.h>
    #include <string.h>
    void bubblesort()
    {
        char a[100];
        int length,j,i,temp;
        printf("请输入一串英文:");
        scanf("%s",a);
        length=strlen(a);
        for(i=1;i<=length;i++)
        {
            for(j=length-1;j>0;j--)
            {
                if(a[j]<a[j-1])
                {
                    temp=a[j];
                    a[j]=a[j-1];
                    a[j-1]=temp;
                }
            }
        }
        printf("升序后结果为:");
        for(j=1;j<=length;j++)
            printf("%c",a[j]);    
    }
    int main()
    {
        bubblesort();
        return 0;
    }
    #include<stdio.h>
    #include<string.h>
    void z()//选择排序法 
    {
        int i,j,l,t,min;
        char a[100];
        printf("请输入字符串:");
        scanf("%s",a);
        l=strlen(a);
        for(i=0;i<l;i++)
        {
            min=i;
            for(j=min+1;j<l;j++)
            {
                if(a[j]<a[min])
                min=j;
            }
            t=a[min];
            a[min]=a[i];
            a[i]=t;
        }
        printf("升序排序为:");
        printf("%s",a);
    }
    int main()
    {
        z();
    return 0;
    }
  • 相关阅读:
    BZOJ4987 Tree
    BZOJ4817 [SDOI2017]树点涂色
    BZOJ4811: [YNOI2017] 由乃的OJ
    BSGS算法
    codeforces914G Sum the Fibonacci
    NOI2018网络同步赛游记
    雅礼集训 2017 Day2 水箱 可并堆
    CTSC&APIO2018游记
    51Nod 有限背包计数问题 题解报告
    CTSC2016&&APIO2016游记
  • 原文地址:https://www.cnblogs.com/160809311-wcy/p/6099944.html
Copyright © 2020-2023  润新知