Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
a6
//Rextester.Program.Main is the entry point for your code. Don't change it. //Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354) using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { int accountleft=0; int accountright=0; int[] test = {2, 2, 5, 4, 4}; int f(int[] a) { int rightside = a.Length-1; int leftside = 0; int middle = a.Length/2; int left=a[0]; int right= a[rightside]; while(true) { if(leftside+1 == rightside && left != right ) { return 0; } else { if(left > right) { right+=a[rightside--]; accountright++; } else if (left < right) { left+=a[leftside++]; accountleft+=1; } else if(left == right) { if(accountleft==0) { accountleft++; } else if(accountright==0) { accountright++; } return 1; } else { return 0; } } } } int final = f(test); if(final==1) { String leftstring=""; String rightstring=""; for(int i=0; accountleft>=i; i++) { leftstring+="a["+i+"]+"; } for(int y=test.Length-1-accountright; y<=test.Length-1; y++) { rightstring+="a["+y+"]+"; } Console.WriteLine(accountleft+1+" Reason:"+leftstring+" is equal to "+rightstring); } else { } // Console.WriteLine(f(test)); Console.WriteLine(accountleft); Console.WriteLine(accountright); Console.WriteLine(test.Length); } } }
run
|
edit
|
history
|
help
0
Easy prgm
Get Round of 5 c# Vishal
UPDJLJ87258 Orderby grouping understanding
Customised Code Dashboard
Reward
Lesson 2
CODE
char.IsNumber
A.K.C#_EXPERIENCE_1
using int.TryParse