Krasimir_Slavov

Untitled

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