卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章16333本站已运行3317

在C语言中编写一个打印数字模式的程序

程序描述

通过接受用户提供的行数来打印数字模式。

输入:5 行

1
6 2
10 7 3
13 11 8 4
15 14 12 9 5

算法

Print the pattern from the end of each Row
Complete the last column of each Row
Start from the Second Last Column of the second row
Repeat till the number of rows specified by the User.

示例

/*Program to print Numeric Pattern */
#include<stdio.h>
int main()
{
   int k, l, m, count=1;
   int rows;
   clrscr();
   printf("

Please enter the number of rows for the Numeric Pattern: "); scanf("%d",&rows); for (k = 1; k <= rows; k++) { m = count; for (l = 1; l <= k; l++) { printf("%d",m); m = m - (rows + l - k); } printf("

"); count = count + 1 + rows - k; } getch(); return 0; }

输出

在C语言中编写一个打印数字模式的程序

在C语言中编写一个打印数字模式的程序

卓越飞翔博客
上一篇: 使用C++编程,找到方程n = x + n * x的解的个数
下一篇: PHP如何对接百度语音情感识别接口?
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏