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 Arrays_MoreEx
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] ingredients = Console.ReadLine().Split();
- int length = int.Parse(Console.ReadLine());
- int counter = 0; // брой на съставките
- int ingredientsLength = ingredients.Length;
- string[] pizzaIngredients = new string[10]; //помощен масив за накрая
- for (int i = 0; i < ingredientsLength; i++)
- {
- if (ingredients[i].Length == length) // ????????
- {
- pizzaIngredients[counter] = ingredients[i];
- Console.WriteLine($"Adding {ingredients[i]}.");
- counter++;
- }
- if (counter == 10)
- {
- break;
- }
- }
- Console.WriteLine($"Made pizza with total of {counter} ingredients.");
- Console.Write("The ingredients are: ");
- for (int i = 0; i < pizzaIngredients.Length; i++)
- {
- if (counter > 1)
- {
- Console.Write(pizzaIngredients[i] + ", ");
- counter--;
- }
- else if (counter == 1)
- {
- Console.Write(pizzaIngredients[i] + ".");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement