Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.17 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Collections.Generic;
  4. namespace task02
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             List<string> MINIMUMS = new List<string>();
  11.             int n = 7000;
  12.            
  13.             for (int i = 0; i < n; i++)
  14.             {
  15.                 List<double> s = new List<double>();
  16.                string[] mas = Console.ReadLine().Split("    ");
  17.                 double chislo, chislo2, chislo3 ;
  18.                
  19.                 for (int g = 0; g < 3; g++)
  20.                 {
  21.                     if (double.TryParse(mas[0], out chislo) && double.TryParse(mas[1], out chislo2) && double.TryParse(mas[2], out chislo3))
  22.                     {
  23.                         s.Add(chislo);
  24.                         s.Add(chislo2);
  25.                         s.Add(chislo3);
  26.                         break;
  27.                     }
  28.                     byte[] a = Encoding.Default.GetBytes(mas[g]); // . = 46 ;  0 = 48
  29.  
  30.                     int sum = 0;
  31.                     int l=0;
  32.                     for (int h = 0; h < a.Length; h++)
  33.                     {
  34.                         l = h;
  35.                         if (a[h] == 46)
  36.                         {
  37.                             for (int b = h; b < a.Length; b++)
  38.                             {
  39.                                 if (a[b] == 48 && a[b+1]!=48)
  40.                                 { sum = sum - 46;
  41.                                     l = b;
  42.                                     h = b;
  43.  
  44.                                 }
  45.                             }                          
  46.                         }
  47.  
  48.                         else
  49.                         {
  50.                             sum = a[h] + sum;
  51.                         }
  52.                     }
  53.                     s.Add(sum);
  54.                    
  55.                 }
  56.                 double min = Math.Min(s[0], s[1]);
  57.                 min = Math.Min(min, s[2]);
  58.                 MINIMUMS.Add(mas[s.IndexOf(min)]);
  59.                
  60.  
  61.             }
  62.             foreach (var c in MINIMUMS)
  63.             {
  64.                 Console.WriteLine(c);
  65.             }
  66.            
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement