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 _06.Largest_Product_Of_Digits
- {
- class Largest_Product_Of_Digits
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- int product = 1;
- int maxProduct = int.MinValue;
- int currentPosition = 0;
- for (int i = 0; i < input.Length; i++)
- {
- for (int j = 0; j < 6; j++)
- {
- product *= Convert.ToInt32(input[currentPosition] - 48);
- if (currentPosition < input.Length - 1)
- {
- currentPosition++;
- }
- }
- if (product > maxProduct)
- {
- maxProduct = product;
- product = 1;
- }
- else
- {
- product = 1;
- }
- currentPosition = i + 1;
- }
- Console.WriteLine(maxProduct);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement