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 Homework9
- {
- class Program
- {
- static void Main(string[] args)
- {
- int goldCount;
- int crystalCount;
- int price = 5;
- bool isEnough;
- Console.Write("Сколько у вас золота: ");
- goldCount = Convert.ToInt32(Console.ReadLine());
- Console.Write("Сколько вы хотите купить алмазов: ");
- crystalCount = Convert.ToInt32(Console.ReadLine());
- isEnough = goldCount >= crystalCount * price;
- goldCount -= crystalCount * price * Convert.ToInt32(isEnough);
- crystalCount *= Convert.ToInt32(isEnough);
- Console.WriteLine($"У вас осталось {goldCount} золота. Вы купили {crystalCount} кристаллов");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment