Advertisement
Ronka

Untitled

Jun 12th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 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 Arrays_MoreEx
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string[] ingredients = Console.ReadLine().Split();
  14. int length = int.Parse(Console.ReadLine());
  15.  
  16. int counter = 0; // брой на съставките
  17. int ingredientsLength = ingredients.Length;
  18.  
  19. string[] pizzaIngredients = new string[10]; //помощен масив за накрая
  20.  
  21. for (int i = 0; i < ingredientsLength; i++)
  22. {
  23. if (ingredients[i].Length == length) // ????????
  24. {
  25. pizzaIngredients[counter] = ingredients[i];
  26. Console.WriteLine($"Adding {ingredients[i]}.");
  27. counter++;
  28. }
  29.  
  30. if (counter == 10)
  31. {
  32. break;
  33. }
  34. }
  35.  
  36. Console.WriteLine($"Made pizza with total of {counter} ingredients.");
  37. Console.Write("The ingredients are: ");
  38.  
  39. for (int i = 0; i < pizzaIngredients.Length; i++)
  40. {
  41. if (counter > 1)
  42. {
  43. Console.Write(pizzaIngredients[i] + ", ");
  44. counter--;
  45. }
  46. else if (counter == 1)
  47. {
  48. Console.Write(pizzaIngredients[i] + ".");
  49. break;
  50. }
  51. }
  52.  
  53.  
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement