Advertisement
NadyaMisheva

zadacha 4 test

Dec 9th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         int kg = int.Parse(Console.ReadLine());
  8.         int days = int.Parse(Console.ReadLine());
  9.         int allgr = 0;
  10.         for (int i = 1; i <= days; i++)
  11.         {
  12.             int gr = int.Parse(Console.ReadLine());
  13.             allgr += gr;
  14.         }
  15.         int g = kg * 1000;
  16.         if(g >= allgr)
  17.         {
  18.             Console.WriteLine("Food is enough! Leftovers: {0} grams.", g - allgr );
  19.         }
  20.         else
  21.         {
  22.             Console.WriteLine("Food is not enough. You need {0} grams more.", allgr - g);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement