如何创建数字模式 [英] how to create a number pattern
本文介绍了如何创建数字模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
5
10 15
15 20 25
20 25 30 35
25 30 35 40 45
解决方案
这不是问题。在看到此解决方案之前,可能会标记它。将来,在你提出这个问题之前,我不会自愿提供解决方案。
你现在应该知道如何在这些论坛上提问。
隐含的查询似乎很简单:
public Enumerable< int> NumberPattern( int n){
int baseNum = 5 跨度>;
for ( int i = n; i < 2 * n; i ++){
yield baseNum * i
}
// 或
for ( int i = 0 ; i < n; i ++){
yield baseNum *(n + i);
}
// 或
int [] result = new int [n] {
for ( int i = 0 ; i < n; i ++){
result [i] = baseNum *(n + i);
}
返回结果;
}
< / int > 跨度>
5
10 15
15 20 25
20 25 30 35
25 30 35 40 45
解决方案
This is not a question. It will probably be flagged before this solution is seen. In future, I will not volunteer a solution until you have asked the question.
You should know by now how to ask a question on these forums.
The implied query seems simple, though:
public Enumerable<int> NumberPattern(int n){ int baseNum = 5; for(int i = n; i < 2*n; i++){ yield baseNum * i } // OR for (int i = 0; i < n; i++){ yield baseNum * (n + i); } //OR int[] result = new int[n]{ for (int i = 0; i < n; i++){ result[i] = baseNum * (n + i); } return result; } </int>
这篇关于如何创建数字模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文