Повторить действие - C#
Формулировка задачи:
Подскажите что и куда нужно дописать, что бы все действия опять начали повторяться с самого начала?
class Program { static void Main(string[] args) { Console.WriteLine("Введите размерность матрицы"); int column = Convert.ToInt16(Console.ReadLine()); int line = column; if (column > 4) { column = 4; line = 4; Console.WriteLine("Размерность больше допустимого предела,\n массиву присвоена размерность 4"); } int[,] array = new int[line, column]; for (int j = 0; j < line; j++) { for (int i = 0; i < column; i++) { Console.Write("Введите элемент массива с индексом:"); Console.Write(j + 1); Console.Write(","); Console.WriteLine(i + 1); int element = Convert.ToInt16(Console.ReadLine()); array[j, i] = element; element = 0; } } Console.WriteLine(); for (int j = 0; j < line; j++) { for (int i = 0; i < column; i++) { Console.Write(array[j, i]); Console.Write(" "); } Console.WriteLine(); } Console.WriteLine("Для продолжения заполнения второй матрицы нажмите Enter"); Console.ReadLine(); int[,] array2 = new int[line, column]; for (int j = 0; j < line; j++) { for (int i = 0; i < column; i++) { Console.Write("Введите элемент массива с индексом:"); Console.Write(j + 1); Console.Write(","); Console.WriteLine(i + 1); int element = Convert.ToInt16(Console.ReadLine()); array2[j, i] = element; element = 0; } } Console.WriteLine(); for (int j = 0; j < line; j++) { for (int i = 0; i < column; i++) { Console.Write(array2[j, i]); Console.Write(" "); } Console.WriteLine(); } Console.WriteLine("Нажмите Enter что бы получить ответ"); Console.ReadLine(); int[,] array3 = new int[line, column]; for (int j = 0; j < line; j++) { for (int i = 0; i < column; i++) { array3[j, i] = array2[j, i] + array[j, i]; } } for (int j = 0; j < line; j++) { for (int i = 0; i < column; i++) { Console.Write(array3[j, i]); Console.Write(" "); } Console.WriteLine(); } Console.ReadLine(); } }
Решение задачи: «Повторить действие»
textual
Листинг программы
while (true) { // остальное сюда, предусмотреть условие выхода из бесконечного цикла }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д