JuliaPetkova

Untitled

Jun 14th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _6_3_05_PizzaIngredients
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string[] arr = Console.ReadLine().Split();
  14. int ingradientLenght = int.Parse(Console.ReadLine());
  15.  
  16. List<string> pizaProducts = new List<string>();
  17. int count = 0;
  18.  
  19. for (int i = 0; i < arr.Length; i++)
  20. {
  21. var currentString = arr[i];
  22.  
  23. if (currentString.Length == ingradientLenght)
  24. {
  25. count++;
  26. Console.WriteLine($"Adding {currentString}.");
  27. pizaProducts.Add(currentString);
  28.  
  29. if (pizaProducts.Count == 10)
  30. {
  31. break;
  32. }
  33. }
  34. }
  35. Console.WriteLine($"Made pizza with total of {count} ingredients.");
  36. Console.WriteLine("The ingredients are: " + string.Join(", ", pizaProducts) + ".");
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment