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

查看所有标签

Iterative Methods for Sparse Linear Systems, Second Edition

Iterative Methods for Sparse Linear Systems, Second Edition

Yousef Saad / Society for Industrial and Applied Mathematics / 2003-04-30 / USD 102.00

Tremendous progress has been made in the scientific and engineering disciplines regarding the use of iterative methods for linear systems. The size and complexity of linear and nonlinear systems arisi......一起来看看 《Iterative Methods for Sparse Linear Systems, Second Edition》 这本书的介绍吧!

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

RGB HEX 互转工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具