Sweet painted.62 2022-06-09 12:29 采纳率: 75%
浏览 79
已结题

根据问题写出一个程序

编写一个带有嵌套for语句的程序,以显示如下模式。
A.
BB
CCC
DDDD
提示:
(1) 外环数为打印行数;
(2) 内环数是每行打印的字母数,这个数字与外环的循环变量之间的关系是什么?
(3) 字母变化的规则是什么?
Write a program with nested for statements to display a pattern as follows.
A
BB
CCC
DDDD
Hint:
(1) The number of outer loop is the number of printed rows;
(2) The number of inner loop is the number of printed letters on each row, and what is the relationship between this number and the loop variable of the outer loop?
(3) What are the rules of the change of letters?

  • 写回答

3条回答 默认 最新

  • ...404 Not Found 2022-06-09 12:36
    关注
    #include<stdio.h>
    #include<ctype.h>
    int main()
    {
        int i,N,j;
        char c;
        printf("请输入打印层数:\n");
        scanf("%d",&N);
        printf("请输入起始字符:\n");
        getchar();
        scanf("%c",&c);
        for(i=1;i<=N;i++)
        {
            for(j=1;j<=i;j++)
                printf("%c",c);
            if(isalpha(c+1))
                c+=1;
            else
            {
                if(isupper(c))
                    c='A';
                else
                    c='a';
            }
            printf("\n");
        }
        return 0;
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 6月17日
  • 已采纳回答 6月9日
  • 创建了问题 6月9日

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行