zoukankan      html  css  js  c++  java
  • 玩玩

    金字塔一样输出字母,如 输入 d

                 a

             a  b  a

        a  b   c  b  a

    a  b  c   d  c   b  a

     代码实现

     #include<stdio.h>

    int main(void)

    {

            char z;

            int j,t,k;

            scanf("%c",&z);

            t=0;

            if(z>='a'&&z<='z')

            {

                    for(int i=0;i<=z-'a';i++)

                    {

                    for(k=z-'a'-t;k>0;k--)

                    {

                            printf("  ");

                            }

                            for(int j=0;j<=i;j++)

                            {

                            printf("%c ",('a'+j));

                            }

                            for(j=1;j<i+1;j++)

                            {

                            printf("%c ",('a'+i-j));

                            }

                            printf("\n");

                            t++;

                    }

            }

            else if(z>='A'&&z<='Z')

            {

                    for(int i=0;i<=z-'A';i++)

                    {

                            for(k=z-'A'-t;k>0;k--)

                            {

                                    printf("  ");

                            }

                            for(int j=0;j<=i;j++)

                            {

                                    printf(" %c",('A'+j));

                            }

                            for(j=1;j<i+1;j++)

                            {

                            printf(" %c",('A'+i-j));

                            }

                            printf("\n");

                            t++;

      }

            }

            return 0;

    }

  • 相关阅读:
    中文分词学习整理
    机器学习
    TimSort学习资料
    小段子
    Load和CPU利用率是如何算出来的
    sql server xml 截断
    System.Security.Cryptography.CryptographicException: 系统找不到指定的文件
    优化笔记: jxrsfxrxx_D_20140916.gz
    优化笔记: 此两个产品每天8点30分开始,要跑一个小时,看看是否有提升空间
    优化笔记:pfyhparopenfundinfotest_D_20140916.gz
  • 原文地址:https://www.cnblogs.com/lucan727/p/3852209.html
Copyright © 2011-2022 走看看