示例#1
0
        public static int FindDigit(String equation)
        {
            string[] stringArrayFirst, stringArraySecond, digitsArray;

            stringArrayFirst = equation.Split('=');

            string equationFirstPart  = stringArrayFirst[0];
            string equationSecondPart = stringArrayFirst[1];


            if (equationFirstPart.Contains('?'))
            {
                stringArraySecond = equationFirstPart.Split('*');

                string equationFirstPartOne = stringArraySecond[0];
                string equationFirstPartTwo = stringArraySecond[1];



                if (equationFirstPartOne.Contains('?'))
                {
                    missingDigit = FindMissingDigits(equationFirstPartOne, equationFirstPartTwo, equationFirstPart, equationSecondPart, 0);
                }
                else if (equationFirstPartTwo.Contains('?'))
                {
                    missingDigit = FindMissingDigits(equationFirstPartOne, equationFirstPartTwo, equationFirstPart, equationSecondPart, 1);
                }
            }
            else if (equationSecondPart.Contains('?'))
            {
                digitsArray = equationFirstPart.Split('*');

                if (digitsArray.Length == 2)
                {
                    int.TryParse(digitsArray[0], out FirstNumber);
                    int.TryParse(digitsArray[1], out SecondNumber);

                    ResultNumber = FirstNumber * SecondNumber;

                    string result = ResultNumber.ToString();

                    missingDigit = int.Parse(result[FindMissingPosition(equationSecondPart)].ToString());
                }
            }
            else
            {
                missingDigit = 0;
            }

            return(missingDigit);
        }
示例#2
0
        public static IActionResult Run([HttpTrigger(
                                             AuthorizationLevel.Anonymous,
                                             "get",
                                             Route = "mul/num1/{num1}/num2/{num2}")] HttpRequest req, int num1, int num2, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            var result = new ResultNumber()
            {
                Result      = num1 * num2,
                CreatedDate = DateTime.Now
            };

            return(new OkObjectResult(result));
        }
示例#3
0
        public static IActionResult Run([HttpTrigger(
                                             AuthorizationLevel.Anonymous,
                                             "post",
                                             Route = "div")] HttpRequest req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            string  requestBody  = new StreamReader(req.Body).ReadToEnd();
            dynamic data         = JsonConvert.DeserializeObject(requestBody);
            var     azureNumbers = JsonConvert.DeserializeObject <Numbers>(requestBody);

            if (azureNumbers.Num2 == 0)
            {
                return(new BadRequestObjectResult("Divide by 0 not possible"));
            }

            var result = new ResultNumber()
            {
                Result      = azureNumbers.Num1 / azureNumbers.Num2,
                CreatedDate = DateTime.Now
            };

            return(new OkObjectResult(result));
        }