Advertisement
RNovachkov

Untitled

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