Advertisement
Guest User

Untitled

a guest
Sep 28th, 2017
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 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 _05_Pizza_Ingredients
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var allIngredients = Console.ReadLine().Split().ToArray();
  14. int lengthOfMyIngredients = int.Parse(Console.ReadLine());
  15. int counter = 0;
  16. var myIngredient = new List<string>();
  17. for (int i = 0; i < allIngredients.Length; i++)
  18. {
  19.  
  20.  
  21. if (allIngredients[i].Length==lengthOfMyIngredients)
  22. {
  23. if (counter > 10)
  24. {
  25. Console.WriteLine($"Made pizza with total of {counter} ingredients.");
  26. Console.WriteLine("The ingredients are: " + string.Join(", ", myIngredient)+".");
  27. return;
  28. }
  29. Console.WriteLine($"Adding {allIngredients[i]}.");
  30. myIngredient.Add(allIngredients[i]);
  31. counter++;
  32.  
  33.  
  34. }
  35. }
  36. Console.WriteLine($"Made pizza with total of {counter} ingredients.");
  37. Console.WriteLine("The ingredients are: " + string.Join(", ", myIngredient)+".");
  38.  
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement