通过接受用户提供的行数来打印数字模式。
输入: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("</p><p> 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("</p><p>"); count = count + 1 + rows - k; } getch(); return 0; }
立即学习“C语言免费学习笔记(深入)”;
以上就是在C语言中编写一个打印数字模式的程序的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号