SHARE
TWEET

Untitled

a guest Sep 9th, 2017 123 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. class Program
  3. {  
  4.     static void Main()
  5.     {
  6.         int num = Math.Abs(int.Parse(Console.ReadLine()));
  7.         int result = FindResult(num);
  8.         Console.WriteLine(result);
  9.     }
  10.  
  11.     static int FindResult(int num)
  12.     {
  13.         int rezult = FindSumOfOdds(num) * FindSumOfEvens(num);
  14.         return rezult;
  15.     }
  16.  
  17.     static int FindSumOfOdds(int num)
  18.     {
  19.         int sumOfOdds = 0;
  20.        
  21.         while (num > 0){
  22.            
  23.             int nextNum = num % 10;
  24.             num /= 10;
  25.             if (nextNum % 2 != 0)
  26.             {
  27.                 sumOfOdds += nextNum;
  28.             }
  29.  
  30.         }
  31.  
  32.         return sumOfOdds;
  33.     }
  34.  
  35.     static int FindSumOfEvens(int num)
  36.     {
  37.         int sumOfEvens = 0;
  38.         while (num > 0)
  39.         {
  40.             int nextNum = num % 10;
  41.             num /= 10;
  42.             if (nextNum % 2 == 0)
  43.             {
  44.                 sumOfEvens += nextNum;
  45.             }
  46.  
  47.         }
  48.  
  49.         return sumOfEvens;
  50.     }
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top