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