算法生成数字模式 [英] algorithm to generate numbers pattern

查看:83
本文介绍了算法生成数字模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我写一个程序来实现这个算法..



写一个算法接受1到9之间的数字并显示模式。

例如,如果输入的数字是5,则应显示以下模式:



a。三角形图案



1



2 1



3 2 1



4 3 2 1



5 4 3 2 1




b。金字塔图案



1



1 2 1



1 2 3 2 1



1 2 3 4 3 2 1



1 2 3 4 5 4 3 2 1





感谢您的回答.. :)

please help me to write a program to implement this algorithm..

write an algorithm to accept number between 1 and 9 and display the pattern.
For example, if the number entered is 5, the following pattern should be displayed:

a. Triangle pattern

1

2 1

3 2 1

4 3 2 1

5 4 3 2 1


b. Pyramid pattern

1

1 2 1

1 2 3 2 1

1 2 3 4 3 2 1

1 2 3 4 5 4 3 2 1


Thanks for your answer.. :)

推荐答案

请不要求你的作业/作业的解决方案,你应该自己做,如果你想学习。
Please don't ask for solutions to your homework/assignments, you should do the by yourself if you want to learn.


这是一个非常基本的算法,你可以在(几乎)可用的每种编程语言中轻松编码。

如果你不能处理它,请阅读一本好的编程教程(或更好的编程书)。
This is a very basic algorithm you may code it easily in (almost) every programming language available.
If you can't deal with it, please, read a good programming tutorial (or better, programming book).


这篇关于算法生成数字模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆