Advertisement
Guest User

Untitled

a guest
May 25th, 2015
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using System.Threading.Tasks;
  8.  
  9. class BiggestTableRow
  10. {
  11.     static void Main()
  12.     {
  13.         string input = Console.ReadLine();
  14.         input = Console.ReadLine();
  15.         var regex = new Regex(@"(-?[0-9\.]+)");
  16.         double sum = double.MinValue;
  17.         double maxSum = double.MinValue;
  18.         var list = new List<string>();
  19.         var maxList = new List<string>();
  20.  
  21.         while (input != "</table>")
  22.         {
  23.             var matches = regex.Matches(input);
  24.             if (matches.Count == 0)
  25.             {
  26.                 sum = double.MinValue;
  27.             }
  28.             foreach (Match match in matches)
  29.             {              
  30.                 sum += Convert.ToDouble(match.ToString());
  31.                 list.Add(match.ToString());                
  32.             }
  33.             input = Console.ReadLine();
  34.             if (sum > maxSum)
  35.             {
  36.                 maxSum = sum;
  37.                 maxList = list.ToList();
  38.             }
  39.             sum = 0;
  40.             list.Clear();
  41.         }
  42.  
  43.         if (maxList.Count == 0)
  44.         {
  45.             Console.WriteLine("no data");
  46.         }
  47.         else
  48.         {
  49.         Console.Write("{0} = ", maxSum);
  50.         Console.WriteLine(string.Join(" + ", maxList));
  51.         }      
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement