Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
a5
//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 = {4, 1, 1, 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+"]+"; } string leftside = leftstring.Remove(leftstring.Length-1, 1); for(int y=test.Length-1-accountright; y<test.Length; y++) { rightstring+="a["+y+"]+"; } string rightside = rightstring.Remove(rightstring.Length-1, 1); Console.WriteLine(accountleft+" Reason:"+leftside+" is equal to "+rightside); } else { } // Console.WriteLine(f(test)); Console.WriteLine(accountleft); Console.WriteLine(accountright); Console.WriteLine(test.Length); } } }
run
|
edit
|
history
|
help
0
Task 1_4
circleTest
CubexSoft2
Game Dev Challenge #1
gen retuen obj
SKYIES
saetr
Trabbd
zasasasa
Variables