Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Lab17
- {
- class MainClass
- {
- public static void Main (string[] args)
- {
- double[,] a = {{2, 4, -6, 7.4},{4.5, -3, 5, 0},
- {9.7, 4.2, -3.8, 2.75},{3.3, -0.6, 0, 3.5}};
- double[,] b = {{-1.2, 3, 0},{2.5, 6.3, 1},{1.1, 2, 4.2}};
- double[,] c = new double[5, 5];
- double[,] d = new double[6, 6];
- for(int i = 0; i < 5; ++i)
- for(int j = 0; j < 5; ++j)
- c[i, j] = (1 + j) * i * i + j;
- for(int i = 0; i < 6; ++i)
- for(int j = 0; j < 6; ++j)
- d[i, j] = Math.Sin(j * i) + 2.2;
- Console.WriteLine("Matrix A:");
- output(a);
- Console.WriteLine("Matrix B:");
- output(b);
- Console.WriteLine("Matrix C:");
- output(c);
- Console.WriteLine("Matrix D:");
- output(d);
- change(a);
- change(b);
- change(c);
- change(d);
- Console.WriteLine("Matrices after change:");
- Console.WriteLine("Matrix A:");
- output(a);
- Console.WriteLine("Matrix B:");
- output(b);
- Console.WriteLine("Matrix C:");
- output(c);
- Console.WriteLine("Matrix D:");
- output(d);
- }
- static double min(double a, double b){
- if (a < b)
- return a;
- else
- return b;
- }
- static void change(double[,] a){
- int n = a.GetLength(0);
- int m = a.GetLength(1);
- double mn = a[0, 0];
- for (int i = 0; i < n; ++i)
- for (int j = 0; j < m; ++j)
- mn = min (a[i, j], mn);
- a [0, 0] = mn;
- }
- static void output(double[,] a){
- int n = a.GetLength(0);
- int m = a.GetLength(1);
- for (int i = 0; i < n; ++i, Console.WriteLine())
- for (int j = 0; j < m; ++j)
- Console.Write ("{0,6:F} ", a[i, j]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement