我正在尝试使用 for 循环在 Visual Basic 中打印平方数列表。我是新手,觉得这很难。我正在编写的程序应该打印数字平方的列表,例如(1、4、9、16 等)。
问问题
7281 次
2 回答
1
Sub Main()
For number As Integer = 1 To 1000
Console.WriteLine("Square of {0} : {1}", number, number * number)
Next
Console.ReadKey()
End Sub
于 2012-08-08T12:56:41.617 回答
1
You could add a counter to your loop then each time the loop is executed increment it. Then inside the loop you would just need to times the counter with itself for the square.
square = counter*counter;
于 2012-08-08T09:02:26.660 回答