C 练习实例23

C 语言教程 · 2019-02-21 17:43:05

题目:打印出如下图案(菱形)。

   *
  ***
 *****
*******
 *****
  ***
   *

程序分析:先把图形分成两部分来看待,前四行一个规律,后三行一个规律,利用双重for循环,第一层控制行,第二层控制列。

程序源代码:

实例

// Created by www.codercto.com on 15/11/9. // Copyright © 2015年 码农教程. All rights reserved. // #include <stdio.h> int main() { int i,j,k; for(i=0;i<=3;i++) { for(j=0;j<=2-i;j++) { printf(" "); } for(k=0;k<=2*i;k++) { printf("*"); } printf("\n"); } for(i=0;i<=2;i++) { for(j=0;j<=i;j++) { printf(" "); } for(k=0;k<=4-2*i;k++) { printf("*"); } printf("\n"); } }

以上实例输出结果为:

   *
  ***
 *****
*******
 *****
  ***
   *

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

New Dark Age

New Dark Age

James Bridle / Verso Books / 2018-7-17 / GBP 16.99

As the world around us increases in technological complexity, our understanding of it diminishes. Underlying this trend is a single idea: the belief that our existence is understandable through comput......一起来看看 《New Dark Age》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

MD5 加密
MD5 加密

MD5 加密工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具