array[j] = temp ;
}
}
}
Q:一列数的规则如下: 1、1、2、3、5、8、13、21、34...... 求第 30
位数是多少, 用递归算
法实现。
答:public class MainClass
{
public static void Main()
{
Console.WriteLine(Foo(30));
}
public static int Foo(int i)
{
if (i <= 0)
return 0;
else if(i > 0 && i <= 2)
return 1;
else return Foo(i -1) + Foo(i - 2);
}
}
Q:编程遍历页面上所有 TextBox 控件并给它赋值为 string.Empty?
答:
foreach (System.Windows.Forms.Control control in this.Controls)
{
if (control is System.Windows.Forms.TextBox)
{
System.Windows.Forms.TextBox
tb
=
(System.Windows.Forms.TextBox)control ;
tb.Text = String.Empty ;
}
}
Q:一个字符串 String=“adadfdfseffserfefsefseetsdg”,找出里面出现次数最多的字
母和出现的次数。