Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace TestConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- //размерность матрицы
- int mSize = 5;
- Random rand = new Random();
- //счётчики
- int i, j;
- double [,] matrix ;
- matrix = new double [mSize,mSize];
- for (i = 0; i < mSize; i++)
- for (j = 0; j < mSize; j++)
- matrix[i, j] = rand.Next(-10000, 10000) / 15.2486;
- printMatrix(matrix, mSize, "F5", 13);
- }
- public static void printMatrix(double[,] matrix, int mSize, string format, int numberSize)
- {
- int i, j, k;
- string space;//храним пробелы
- string toStr;//число преобразованное в строку
- for (i = 0; i < mSize; i++)
- {
- for (j = 0; j < mSize; j++)
- {
- toStr = matrix[i,j].ToString(format);
- for (k = toStr.Length, space = ""; k < numberSize; k++) space += " ";
- Console.Write(space + toStr + " ");
- }
- Console.Write(Environment.NewLine);
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment