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 Learn1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int price = 10;
- int crystall = 0;
- Console.WriteLine("Введите количество золота которое находится у вас: ");
- int money = Convert.ToInt32(Console.ReadLine());
- int maxBuy = money / price;
- Console.WriteLine($"У вас {money} золота, кристалл стоит 10 золотых,у вас хватает на {maxBuy} кристаллов,сколько вы хотите купить?");
- int buyCount = Convert.ToInt32(Console.ReadLine());
- buyCount -= Convert.ToInt32(buyCount * price > money) * (buyCount - money / price);
- crystall += buyCount;
- money -= buyCount * price;
- Console.WriteLine($"Вы купили {crystall} кристаллов,у вас осталось {money} золотых");
- }
- }
- }
Add Comment
Please, Sign In to add comment