Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _02_ApplesAndOranges
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- //string input = "112";
- int sumOfEvenDigits = 0;
- int sumOfOddDigits = 0;
- for (int i = 0; i < input.Length; i++)
- {
- if ((int)Char.GetNumericValue(input[i]) % 2 == 1)
- {
- sumOfOddDigits += (int)Char.GetNumericValue(input[i]);
- }
- else if ((int)Char.GetNumericValue(input[i]) % 2 == 0)
- {
- sumOfEvenDigits += (int)Char.GetNumericValue(input[i]);
- }
- }
- if (sumOfOddDigits > sumOfEvenDigits)
- {
- Console.WriteLine("oranges " + sumOfOddDigits);
- }
- else if (sumOfEvenDigits > sumOfOddDigits)
- {
- Console.WriteLine("apples " + sumOfEvenDigits);
- }
- else if (sumOfOddDigits == sumOfEvenDigits)
- {
- Console.WriteLine("both " + sumOfEvenDigits);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement