输入一段字符串,无论是否有重复元素出现,都只打印一次出现过的大写字母和小写字母, 且按字母表顺序打印。(如输入AaAa!!zZzZ, 只打印A Z a z)

#include
#include
#include
#include

//排序
void Sorted(char buf0[],int len)
    {
    int y=0,z=0;
    for (y=0;y1;y++)   //int y,z,len;
        {
        for (z=0;z1;z++)
            {
            if (buf0[z]>buf0[z+1])
                {
                char c;
                c=buf0[z];
                buf0[z]=buf0[z+1];
                buf0[z+1]=c;
                }
            }
        }
    }

 //打印字符串
void Print(char *str,int len)
    {
       int i=0;
       char c;
       while (istr[i]!='\0')
           {
             c=str[i];
             printf ("%c",str[i]);
             ++i;
             if (c==str[i])
                 {
                 ++i;
                 continue;
                 }
           }
    }

void List(char *str,int length)
    {
    char buf0[100];
    int i=0,j=0,k=0;
    int len;
    while ((str[i]!='\0')&&iif (islower (str[i])||isupper (str[i]))
            {
            buf0[j]=str[i];
            ++i;
            ++j;
            }
        else
            i++;
        }
    buf0[j]='\0';

    len=strlen (buf0);
    Sorted(buf0, len);
    Print(buf0,len);  //打印

    }

int main(void)
    {

    char buf1[100]={'\0'};
    int len;
    printf ("请输入字符串:\n");
    gets (buf1);
    len=strlen (buf1);
    List (buf1,len);
    system("pause");
    return 0;
    }

你可能感兴趣的:(C语言)