System.FormatException - C#
Формулировка задачи:
Листинг программы
- using System;
- namespace CsLessons
- {
- class SumInLoop
- {
- public static void Main(string[] args)
- {
- int n = Convert.ToInt32(Console.ReadLine());
- int[] sum = new int[n];
- string second = null;
- for (int i = 0; i < n; ++i)
- {
- second = Console.ReadLine();
- string[] numbers = second.Split(' ');
- sum[i] = 0;
- foreach (string element in numbers)
- {
- sum[i] += Convert.ToInt32(element);
- }
- }
- foreach (int element in sum)
- {
- Console.Write(element.ToString() + " ");
- }
- }
- }
- }
Решение задачи: «System.FormatException»
textual
Листинг программы
- using System;
- namespace CsLessons
- {
- class SumInLoop
- {
- public static void Main(string[] args)
- {
- int n = Convert.ToInt32(Console.ReadLine());
- int[] sum = new int[n];
- string second = null;
- for (int i = 0; i < n; ++i)
- {
- second = Console.ReadLine();
- string[] numbers = second.Split(' ');
- Console.WriteLine(numbers[0]);
- Console.ReadKey();
- sum[i] = 0;
- foreach (string element in numbers)
- {
- sum[i] += Convert.ToInt32(element);
- }
- }
- foreach (int element in sum)
- {
- Console.Write(element.ToString() + " ");
- }
- }
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д