要打印n的m倍,请首先设置m和n的值-
int n = 6, m = 1;
现在循环遍历m的值,将其递增并在每次迭代中与n相乘-
while (m <= 5) { //乘n * m- m++; }
让我们看完整的代码-
using System; public class Demo { public static void Main() { int n = 6, m = 1; while (m <= 5) { Console.WriteLine(" {0} \n ", n * m); m++; } } }
输出结果
6 12 18 24 30