Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace MultiplyEvensByOdds
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number = Math.Abs(int.Parse(Console.ReadLine()));
- int odd = 0;
- int even = 0;
- int sum = 0;
- odd = GetSumOddDigits(number, odd);
- even = GetSumEvenDigits(number, even);
- sum = GetMultipleEvenAndOddDigits(odd, even, sum);
- Console.WriteLine(sum);
- }
- static int GetSumOddDigits(int number, int odd)
- {
- for (int i = 0; i < number.ToString().Length; i++)
- {
- if (number.ToString()[i] % 2 == 1)
- {
- odd += number.ToString()[i] - 48;
- }
- }
- return odd;
- }
- static int GetSumEvenDigits(int number, int even)
- {
- for (int i = 0; i < number.ToString().Length; i++)
- {
- if (number.ToString()[i] % 2 == 0)
- {
- even += number.ToString()[i] - 48;
- }
- }
- return even;
- }
- static int GetMultipleEvenAndOddDigits(int odd, int even, int sum)
- {
- return odd * even;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement