Advertisement
Guest User

Untitled

a guest
Sep 28th, 2017
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace P05_PizzaIngredients
  6. {
  7.     class P05_PizzaIngredients
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var ingredients = Console.ReadLine()
  12.                 .Split(' ')
  13.                 .ToArray();
  14.             var maxIngredientLenght = int.Parse(Console.ReadLine());
  15.             int ingredientsCount = 0;
  16.             var addedIngredients = new List<string>();
  17.             for (int i = 0; i < ingredients.Length && ingredientsCount < 10; i++)
  18.             {
  19.                 if (ingredients[i].Length == maxIngredientLenght)
  20.                 {
  21.                     addedIngredients.Add(ingredients[i]);
  22.                     Console.WriteLine($"Adding {ingredients[i]}.");
  23.                     ingredientsCount++;
  24.                 }
  25.             }
  26.             Console.WriteLine($"Made pizza with total of {ingredientsCount} ingredients.");
  27.             Console.WriteLine($"The ingredients are: {string.Join(", ", addedIngredients)}.");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement