C#中这种计算能用循环语句编写吗?
1个回答

static int pos(int i)

{

return i % 3 == 0 ? 3 : i % 3;

}

static int[] a = null, x = null, y = null, z = null;

static void Main(string[] args)

{

a = new int[4];

x = new int[] { 0, 1, 2, 3 };

y = new int[] { 0, 4, 5, 6 };

for (int i = 1; i <= 3; i++)

{

int m = pos(i + 1), n = pos(i + 2);

a[i] = x[m] * y[n] - x[n] * y[m];

Console.WriteLine("a{0}=x{1}*y{2}-x{2}*y{1}t={3}*{4}-{5}*{6}t={7}", i, m, n, x[m], y[n], x[n], y[m], a[i]);

}

Console.ReadKey();

}