Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
707 B
0
Indexable
Never
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();
    }
}