Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp12
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int a, b, i, min, max, sum;
  14.             bool ok;
  15.             i = 1;
  16.             b = 0;
  17.            
  18.            
  19.  
  20.             do { Console.WriteLine("введите кол-во эл-в ");
  21.                 ok = Int32.TryParse(Console.ReadLine(), out a);
  22.                 if (a <= 0)
  23.                 { Console.WriteLine("ошибка");
  24.                 }
  25.  
  26.             } while (!ok);
  27.             max = b;
  28.             min = b;
  29.            
  30.             do
  31.             {
  32.  
  33.                 do
  34.  
  35.                 {
  36.                     Console.WriteLine("введите элементы {0}", i);
  37.                     ok = Int32.TryParse(Console.ReadLine(), out b);
  38.  
  39.                 } while (!ok);
  40.                 if (max > b) { b=max; }
  41.                 if (min < b) { b=min; }
  42.  
  43.                 i++;
  44.                 sum = (min + max);
  45.             } while (i <= a);
  46.  
  47.            
  48.             Console.WriteLine("The sum = {0}",sum);
  49.            
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement