Advertisement
braveheart1989

18.Equal_Pairs

Feb 14th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 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 _13.Equal_Pairs
  8. {
  9.     class Equal_Pairs
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int number = int.Parse(Console.ReadLine());
  14.  
  15.             int n = int.Parse(Console.ReadLine());
  16.             int n1 = int.Parse(Console.ReadLine());
  17.  
  18.             //1. Първата сума е равна на: sum = n + n1;
  19.             int sum = n + n1;
  20.             int maxDiff;
  21.             int tempSum;
  22.  
  23.             //2.Използване на for-цикъл от i=1;
  24.             for (int i = 1; i < number; i++)
  25.             {
  26.                 n = int.Parse(Console.ReadLine());
  27.                 n1 = int.Parse(Console.ReadLine());
  28.  
  29.                 //3. Въвеждане на променлива за всяка 2-ка суми:
  30.                 tempSum = n + n1;
  31.  
  32.                 //4. Въвеждане на променлива за отчитане на разликата между сумите:
  33.                 maxDiff = sum - tempSum;
  34.  
  35.                 //5. Сравняване на първоначалната сума с временната ако са еднакви: Yes, value=
  36.                 if (sum - tempSum==0)
  37.                 {
  38.                     Console.WriteLine("Yes, value={0}", sum);
  39.                 }
  40.                 else
  41.                 {
  42.                     maxDiff = sum - tempSum;
  43.                     Console.WriteLine("No, maxdiff={0}", Math.Abs(maxDiff));
  44.                 }
  45.             }
  46.            
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement