Untitled

 avatar
unknown
plain_text
2 years ago
707 B
2
Indexable
using System;
using System.Collections.Generic;
using System.Threading;

class Program
{
    static List<int> list = new List<int>();
    static void Main(string[] args)
    {
        Thread t = new Thread(() =>
        {
            int n = 0;
            do
            {
                n = int.Parse(Console.ReadLine());
                if (n != -1)
                {
                    list.Add(n);
                }
            } while (n != -1);
        });
        t.Start();
        t.Join();
        int sum = 0;
        foreach (int n in list)
        {
            sum += n;
        }
        Console.WriteLine("Sum: " + sum);
        Console.ReadKey();
    }
}
Editor is loading...