Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Numerics;
- namespace Project_euler_13
- {
- class Program
- {
- static void Main(string[] args)
- {
- TextReader tr = new StreamReader("tall.txt");
- int linenumber = 0;
- BigInteger[] digits = new BigInteger[101];
- BigInteger line;
- BigInteger sum = 0;
- string linje;
- if (File.Exists("tall.txt"))
- {
- //while ((line = long.Parse(tr.ReadLine())) != null)
- for (int r = 0; r <= 100; r++)
- {
- linenumber++;
- linje = tr.ReadLine();
- if (linje != null)
- {
- digits[linenumber] = BigInteger.Parse(linje);
- }
- }
- }
- else
- {
- File.Create("tall.txt");
- }
- Console.WriteLine("From array: ");
- for (int x = 1; x <= 100; x++)
- {
- Console.WriteLine(digits[x].ToString());
- sum += digits[x];
- }
- Console.WriteLine("\n\n");
- Console.WriteLine("Total: " + sum);
- Console.WriteLine("\nThe 10 first: "+sum.ToString().Substring(0, 10));
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement