求大神解答一到c题目字母塔……

求字母塔输出………………………………………………………………………………………………………………………………………………………………………………………………………………………………图片说明

方法可能比较蠢,但是可行
java代码

public class 输出字母塔 {
    public static void main(String[] args) {
        char ch = 'A'-1;
        int x = 0;
        int col = 1;//这里的col控制每行字母个数
        int line = 0;
    while(x<26){//这个循环用于统计行数
        for(int y = 0; y<col; y++,x++){
            ch = (char)(ch+1);//这里强转
            //System.out.print(ch);
        }
        col += 2;//下一行递增2
        line++;//统计行数
        //System.out.print("\n");
    }
    x = 0;ch = 'A'-1;col = 1;//重置全局变量
    while(x<26){//这个循环用于输出字母塔
        for(int p=0; p<line-1; p++){//先输出前面空格
            System.out.print(" ");//输出line-1个空格
        }
        line--;//下一行空格数又减一
        for(int y = 0; y<col; y++,x++){
            if(x>=26)
                break;
            ch = (char)(ch+1);//这里对'A'+y转换成后面的字母
            System.out.print(ch);
        }
        col += 2;//下一行递增2
        System.out.print("\n");
    }
    }

}

c两年没碰了,不过差不多应该如下:

#include <stdio.h>
#include <stdlib.h>
        char ch = 'A'-1;
        int x = 0;
        int col = 1;//这里的col控制每行字母个数
        int line = 0;
    while(x<26){//这个循环用于统计行数
        for(int y = 0; y<col; y++,x++){
            ch = (char)(ch+1);//这里强转
            //printf("%s",ch);
        }
        col += 2;//下一行递增2
        line++;//统计行数
        //printf("\n");
    }
    x = 0;ch = 'A'-1;col = 1;//重置全局变量
    while(x<26){//这个循环用于输出字母塔
        for(int p=0; p<line-1; p++){//先输出前面空格
            printf(" ");//输出line-1个空格
        }
        line--;//下一行空格数又减一
        for(int y = 0; y<col; y++,x++){
            if(x>=26)
                break;
            ch = (char)(ch+1);//这里对'A'+y转换成后面的字母
            printf("%s",ch);
        }
        col += 2;//下一行递增2
        printf("\n");
    }
    }

}

求源码……………………

网上搜搜就有了 有问题可以先自己查找资源 若实在没有可以通过发帖请求各位帮助 祝你在学习的道路上不断前进

#include
#include
int main()
{
int t=65,l=1;//t代表要输出的字符的ASCLL码,l代表本轮要输出字符的个数
for(int i=1;i<=5;i++)//五行的字母塔
{
for(int j=5-i;j>=1;j--)//因为要输出5-i个空格,所以j=5-i
{
printf(" ");
}
for(int j=1;j<=l;j++)//输出字母
{
printf("%c",t);
t++;//ASCLL码增加一
}
l+=2;//每轮输出的字符多两个
printf("\n");//换行输出
}
return 0;//结束
}

有问题百度或者谷歌,找不到在来csdn~,祝你在学习的道路上不断前进;