c#中以三角形格式打印的数字 [英] print number in triangular format in c#

查看:39
本文介绍了c#中以三角形格式打印的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的采访做准备所以请你告诉我如何用c打印这个#



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



请尽快告诉我.....

提前致谢....

解决方案

< blockquote>尝试:

 Console.WriteLine(  1 ); 
Console.WriteLine( 1 2 1);
Console.WriteLine( 1 2 3 2 1);
Console.WriteLine( 1 2 3 4 3 2 1);
Console.WriteLine( 1 2 3 4 5 4 3 2 1);



如果你的意思是请写下代码来动态完成这项工作,这样我得到的工作我不配,也做不到,那么我真的认为你应该自己写一下,好像你不能让我不想在你旁边工作!


一个 for loop [ ^ ]以及字符串连接 [ ^ ]应该作为你进一步行动的暗示。


I am preparing for my interview so could you please tell me how do i print this in c#

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 tell me ASAP.....
Thanks in advance....

解决方案

Try:

Console.WriteLine("1");
Console.WriteLine("1 2 1");
Console.WriteLine("1 2 3 2 1");
Console.WriteLine("1 2 3 4 3 2 1");
Console.WriteLine("1 2 3 4 5 4 3 2 1");


If you mean "Please write the code to do this dynamically so I get a job I don''t deserve and can''t do", then I really think you should write it yourself, as if you can''t I for one do not want to work next to you!


A for loop[^] along with string concatenation[^] should act as a hint for you to proceed further.


这篇关于c#中以三角形格式打印的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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