The Angry Cat
На ето тази задача когато задам проверка array[i] < number изобщо не влиза в нея, Някой може ли да ми каже защо???
jonh is very angry with his owner because he left him alone during the teamwork defenses for the programming fundamentals course at softuni.it s time for jonh to get his payback and he will do it by breaking various household items.
each item has a price rating a number that describes how valuable that item is for jonh s owner. you will be given an entry point from which jonh will break the items to his left and then to his right. jonh will never break the item at his entry point.
you must calculate the damage to both his left and right then print only the bigger damage to the household.if both sums are equal print the left one.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Regexs
{
class Program
{
static void Main(string[] args)
{
int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
int number = int.Parse(Console.ReadLine());
string input = Console.ReadLine();
int leftcheapsum = 0;
int rightcheapsum = 0;
int leftexpensivesum = 0;
int rightexpensivesum = 0;
for (int i = 0; i < array.Length; i++)
{
if (input == "cheap")
{
if (array[i] < number)
{
if (i < number)
{
leftcheapsum = leftcheapsum + array[i];
}
if (i > number)
{
rightcheapsum = rightcheapsum + array[i];
}
}
}
if (input == "expensive")
{
if (array[i] >= number)
{
if (i < number)
{
leftexpensivesum = leftexpensivesum + array[i];
}
if (i > number)
{
rightexpensivesum = rightexpensivesum + array[i];
}
}
}
}
if (input == "cheap")
{
if (leftcheapsum >= rightcheapsum)
{
Console.WriteLine($"left - {leftcheapsum}");
}
else
{
Console.WriteLine($"right - {rightcheapsum}");
}
}
if (input == "expensive")
{
if (leftexpensivesum >= rightexpensivesum)
{
Console.WriteLine($"left - {leftexpensivesum}");
}
else
{
Console.WriteLine($"right - {rightexpensivesum}");
}
}
}
}
}