Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _10.MultiplyEvensByOdds
- {
- class Program
- {
- static void Main(string[] args)
- {
- int input = Math.Abs(int.Parse(Console.ReadLine()));
- Console.WriteLine(GetMultipliesOffEvenAndOdds(input));
- }
- static int GetMultipliesOffEvenAndOdds(int a)
- {
- int result = GetSumOfOddDigits(a) * GetSumEvenDigits(a);
- return result;
- }
- static int GetSumEvenDigits(int number)
- {
- int sum = 0;
- while (number != 0)
- {
- int lastDigit = number % 10;
- if (lastDigit % 2 == 0)
- {
- sum += lastDigit;
- }
- number /= 10;
- }
- return sum;
- }
- static int GetSumOfOddDigits(int number)
- {
- int sum = 0;
- while (number != 0)
- {
- int lastDidit = number % 10;
- if (lastDidit % 2 == 1)
- {
- sum += lastDidit;
- }
- number /= 10;
- }
- return sum;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement