Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Odd and Even Product
using System; namespace Rextester { public class Program { public static void Main(string[] args) { int n = 5; string input = "4 3 2 5 2"; int[] numbers = new int[6]; numbers = Converter(input); int resultOdd = 1; int resultEven= 1; //Calculates odd result for (int i = 0; i < n; i = i + 2) { resultOdd *= numbers[i]; } for (int i = 1; i < n; i = i + 2) { resultEven *= numbers[i]; } if (resultOdd == resultEven) { Console.WriteLine("yes"); Console.WriteLine("product = {0}", resultOdd); } else { Console.WriteLine("no"); Console.WriteLine("odd_product = {0}", resultOdd); Console.WriteLine("even_product = {0}", resultEven); } } public static int[] Converter(string input) { string[] inputString = input.Split(' '); int[] intArray = new int[inputString.Length]; for (int i = 0; i < inputString.Length; i++) { intArray[i] = int.Parse(inputString[i]); //Console.WriteLine(intString[i]); } return intArray; } } }
run
|
edit
|
history
|
help
0
input
Regex - Leading zeros
neja]\
2
List<Action>()
7. Asynchrony
thread kill
fnaf
8
ReplaceNotExpectedCharacters