alexey3017

1.6 - Магазин

Mar 19th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 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. namespace Learn1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int price = 10;
  13.             int crystall = 0;
  14.  
  15.             Console.WriteLine("Введите количество золота которое находится у вас: ");
  16.             int money = Convert.ToInt32(Console.ReadLine());
  17.             int maxBuy = money / price;
  18.  
  19.             Console.WriteLine($"У вас {money} золота, кристалл стоит 10 золотых,у вас хватает на {maxBuy} кристаллов,сколько вы хотите купить?");
  20.             int buyCount = Convert.ToInt32(Console.ReadLine());
  21.  
  22.             buyCount -= Convert.ToInt32(buyCount * price > money) * (buyCount - money / price);
  23.             crystall += buyCount;
  24.             money -= buyCount * price;
  25.  
  26.             Console.WriteLine($"Вы купили {crystall} кристаллов,у вас осталось {money} золотых");
  27.         }
  28.     }
  29. }
Add Comment
Please, Sign In to add comment