Advertisement
radidim

EqualSums (C# Shell App Paste)

Oct 5th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. namespace Program
  3. {
  4.     using System;
  5.     using System.Linq;
  6.  
  7.     public class EqualSums
  8.     {
  9.         public static void Main()
  10.         {
  11.             int[] a = Console.ReadLine()
  12.             .Split()
  13.             .Select(int.Parse)
  14.             .ToArray();
  15.             int l=0;
  16.             int r=0;
  17.             int mitte=-1;
  18.             for(int i = 0;i < a.Length;i++)
  19.             {
  20.                 mitte = a[i];
  21.                 for(int j=i;j<a.Length-1;j++)
  22.                 {
  23.                     if(mitte>=a.Length-1)
  24.                     {
  25.                         r=0;
  26.                     }
  27.                     else
  28.                     {
  29.                         r+=a[j+1];
  30.                        
  31.                     }
  32.                 }
  33.                 for(int k=a[i];k>=0;k--)
  34.                 {
  35.                     if(mitte<=a[i])
  36.                     {
  37.                         l=0;
  38.                     }
  39.                     else{
  40.                         l+=a[k+1];
  41.                     }
  42.                 }
  43.             }
  44.                 if(l==r)
  45.                 {
  46.                     Console.Write(mitte);
  47.                 }
  48.                 else{
  49.                     Console.Write("no");
  50.                 }
  51.            
  52.            
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement