Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _05b__Arrays_Exercises
- {
- class Arrays_Exercises
- {
- static void Main(string[] args)
- {
- string[] ingredients = Console.ReadLine().Split(' ').ToArray();
- int ingredientLength = int.Parse(Console.ReadLine());
- string[] finalIngredients = new string[ingredients.Length];
- int counter = 0;
- for (int i = 0; i < ingredients.Length; i++)
- {
- if (ingredients[i].Length == ingredientLength)
- {
- finalIngredients[i] += ingredients[i];
- Console.WriteLine($"Adding {ingredients[i]}.");
- counter++;
- if (counter >= 10)
- {
- break;
- }
- }
- }
- Console.WriteLine($"Made pizza with total of {counter} ingredients.\r\nThe ingredients are: {string.Join(", ", finalIngredients.Where(x => !string.IsNullOrEmpty(x)))}.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment