使用c语言嵌套循环打印以下图案:

原问题:使用c语言嵌套循环打印以下图案:
分类:编程开发 > 最后更新时间:【2017-02-03 15:12:40】
问题补充:

A

BC

DEF

GHIJ

KLMNO

PQRSTU

最佳答案

#include <stdio.h>

void main()

{

char start = 'A'; //声明首字母

for (int i = 1; i <= 6; i++)

{

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

{

printf("%c", start); //打印每个字符

start += 1; //由于输入的字母临近,加一就可以得到下一个字母

}

printf("\n"); //每行结束后换行

}

system("pause"); //暂停查看结果

}

最佳答案由网友  沉默三棱镜  提供
公告: 为响应国家净网行动,部分内容已经删除,感谢网友理解。
10

分享到:

其他回答

其它网友回答:
#include <stdio.h>

其它网友回答:
int main (void)

其它网友回答:
{

其它网友回答:
      int count1, count2, lineNum = 1;

其它网友回答:
      char ch = 'A';

其它网友回答:
      for (count1 = 0; count1 < 6; count1++)

其它网友回答:
      {

其它网友回答:
            for (count2 = 0; count2 < lineNum; count2++)

其它网友回答:
            printf ("%c", ch++);

其它网友回答:
            printf ("\n");

其它网友回答:
            lineNum++;

其它网友回答:
      }

其它网友回答:
}

其它网友回答:


追答:
第二个for语句下面的printf()语句忘记缩进了。
    推荐