kvadrat4o

ControlNumber

Mar 27th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2.  
  3. namespace March_Evening_06ControlNumber
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             //Console.WriteLine("enter first number N: ");
  10.             int N = int.Parse(Console.ReadLine());
  11.             //Console.WriteLine("enter second number M: ");
  12.             int M = int.Parse(Console.ReadLine());
  13.             //Console.WriteLine("enter control number number C: ");
  14.             int C = int.Parse(Console.ReadLine());
  15.             int sum,counter;
  16.             sum = 0;
  17.             counter = 0;
  18.             for (int i = 1; i<=N; i++) {
  19.                 for (int j = M; j>=1; j--) {
  20.                     sum = N*2+M*3;
  21.                     counter++;
  22.                     if (sum>=C) {
  23.                         Console.WriteLine("{0} moves \nScore: {1} >= {2}",counter,sum,C);
  24.                         break;
  25.                     }
  26.                 }
  27.                 if (sum>=C) {
  28.                         break;
  29.                     }
  30.                 counter++;
  31.                
  32.             }
  33.             if (sum<C) {
  34.                
  35.                 Console.WriteLine("{0} moves",counter);
  36.             }
  37.             // TODO: Implement Functionality Here
  38.            
  39.             Console.Write("Press any key to continue . . . ");
  40.             Console.ReadKey(true);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment