Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. public class PuzzleA
  2. {
  3.     private const int CycleCount = 6;
  4.  
  5.     public static void Main(string[] args)
  6.     {
  7.         PuzzleB[] list = new PuzzleB[6];
  8.  
  9.         int y = 1;
  10.  
  11.         for (var i = 0; i < CycleCount; i++)
  12.         {
  13.             list[i] = new PuzzleB();
  14.             list[i].value = y;
  15.             y = y * 10;
  16.         }
  17.  
  18.         int result = 0;
  19.         for (int i = CycleCount; i > 0; i--)
  20.         {
  21.             int index = i - 1;
  22.             PuzzleB element = list[index];
  23.             result += element.Calculate(index);
  24.         }
  25.  
  26.         Debug.Log("Result" + result);
  27.     }
  28. }
  29.  
  30. public class PuzzleB
  31. {
  32.     public int value;
  33.     private const int MaxValue = 100;
  34.  
  35.     public int Calculate(int factor)
  36.     {
  37.         if (value > MaxValue)
  38.         {
  39.             return value * factor;
  40.         }
  41.         else
  42.         {
  43.             return value * (5 - factor);
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement