Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Linq;
- namespace _02_Make_a_Salad
- {
- class Program
- {
- static void Main(string[] args)
- {
- Queue vegies = new Queue(Console.ReadLine().Split());
- Stack calories = new Stack(Console.ReadLine().Split().Select(int.Parse).ToList());
- Queue madeSalads = new Queue();
- while (true)
- {
- if (calories.Count <= 0) break;
- if (vegies.Count <= 0) break;
- int saladCal = (int)calories.Peek();
- while (true)
- {
- string vegetable = (string)vegies.Dequeue();
- switch (vegetable)
- {
- case "tomato":
- saladCal -= 80;
- break;
- case "carrot":
- saladCal -= 136;
- break;
- case "lettuce":
- saladCal -= 109;
- break;
- case "potato":
- saladCal -= 215;
- break;
- }
- if (saladCal <= 0)
- {
- int num = (int)calories.Pop();
- madeSalads.Enqueue(num);
- break;
- }
- if (vegies.Count <= 0) break;
- }
- }
- foreach (var salad in madeSalads)
- {
- Console.Write(salad + " ");
- }
- Console.WriteLine();
- if (vegies.Count > 0)
- {
- foreach (var veg in vegies)
- {
- Console.Write(veg + " ");
- }
- Console.WriteLine();
- }
- if (calories.Count > 0)
- {
- foreach (var cal in calories)
- {
- Console.Write(cal + " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement