Advertisement
programigo

Цикли - Задача 8

Feb 19th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 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. public class Program
  8. {
  9.     public static void Main()
  10.     {
  11.         int n = int.Parse(Console.ReadLine());
  12.         int firstSum = 0;
  13.         int secondSum = 0;
  14.  
  15.         for (int i = 0; i < n; i++)
  16.         {
  17.             int currentNumber = int.Parse(Console.ReadLine());
  18.             firstSum += currentNumber;
  19.         }
  20.  
  21.         for (int i = 0; i < n; i++)
  22.         {
  23.             int currentNumber = int.Parse(Console.ReadLine());
  24.             secondSum += currentNumber;
  25.         }
  26.  
  27.         if (firstSum == secondSum)
  28.         {
  29.             Console.WriteLine($"Yes, sum = {firstSum}");
  30.         }
  31.         else
  32.         {
  33.             Console.WriteLine($"No, diff = {Math.Abs(firstSum - secondSum)}");
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement