- //数组倒置
- class Program
- {
- static void Main(string[] args)
- {
- int[,] a = new int[,] { {1,3,5,7},{9,8,7,8},{5,89,56,8},{56,78,98,0}};
- Console.WriteLine("数组倒置前的结果:");
- for (int i = 0; i < 4; i++)
- {
- for (int j = 0; j < 4; j++)
- {
- Console.Write(a[i,j].ToString());
- Console.Write(" ");
- }
- Console.WriteLine();
- }
- int m;
- for (int x = 0; x < 4;x++ )
- {
- for (int y = x + 1; y < 4; y++)
- {
- m = a[x, y];
- a[x, y]=a[y, x];
- a[y, x] = m;
- }
- }
- Console.WriteLine("数组倒置后的结果是:");
- for (int i = 0; i < 4;i++ )
- {
- for (int j = 0; j < 4; j++)
- {
- Console.Write(a[i,j].ToString());
- Console.Write(" ");
- }
- Console.WriteLine();
- }
- }
- }
- //阶乘
- static long jc(long num)
- {
- if (num > 0)
- {
- return num *jc (num - 1);
- }
- else
- {
- return 1;
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/0109201513596.html
来源: http://www.codesnippet.cn/detail/0109201513596.html