程序说明
数字模式是根据称为模式规则的规则创建的数字序列。模式规则可以使用一个或多个数学运算来描述序列中连续数字之间的关系。
模式示例
模式 1
12 63 7 104 8 11 135 9 12 14 15
登录后复制
模式 2
1 1 2 3 1 2 3 4 5 1 2 3 4 5 6 71 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 1 2 3 4 5 1 2 3 1
登录后复制
算法
Pattern 1:i stands for rows and j stands for columns.5 stands for making pattern for 5 Rows and ColumnsLoop for each Row (i)K is initialized to iLoop for each Column (j)Do the Pattern for the current Column (j)Display the Value of KReinitialize the Value of K = k + 5 - jPattern 2:First Row: Display 1Second Row: Display 1,2,3Third Row: Display 1,2,3,4,5Fourth Row: Display 1,2,3,4,5,6,7Fifth Row: Display 1,2,3,4,5,6,7,8,9Display the same contents from 4th Row till First Row below the fifth Row.
登录后复制
示例
/* Program to print Numeric Pattern */#includeint main(){ int i,j,k; printf("Numeric Pattern 1"); printf(""); printf("
"); for(i=1;i
"); } printf("
"); printf("Numeric Pattern 2"); printf("
"); printf("
"); for(i = 1;i
"); } for(i = 4;i>=1;i--){ for(j = 5;j>i;j--){ printf(" "); } for(k = 1;k
"); } getch(); return 0;}
登录后复制
输出
立即学习“C语言免费学习笔记(深入)”;
以上就是编写一个在C语言中打印数字模式的程序的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2583561.html