ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1493. One Step from Happiness

test 8 c# help please
Posted by Alexander_Real_Under 18 Jun 2024 20:27
my code



using System;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;

namespace Program;

public static class Program
{


public static void Main()
    {
        int number = Convert.ToInt32(Console.ReadLine());
        string number_plus = Convert.ToString(number + 1);
        string number_minus = Convert.ToString(number - 1);
        char[] massiv_plus = number_plus.ToCharArray();
        char[] massiv_minus = number_minus.ToCharArray();
        string str_minus;
        string str_plus;
        while (massiv_minus.Length < 6)
        {
            str_minus = String.Join("", massiv_minus.Reverse());
            str_minus += '0';
            massiv_minus = str_minus.ToCharArray();
            massiv_minus.Reverse();
        }
        while (massiv_plus.Length < 6)
        {
            str_plus = String.Join("", massiv_plus.Reverse());
            str_plus += '0';
            massiv_plus = str_plus.ToCharArray();
            massiv_plus.Reverse();
        }
        int a1_plus = Convert.ToInt32(massiv_plus[0]);
        int a2_plus = Convert.ToInt32(massiv_plus[1]);
        int a3_plus = Convert.ToInt32(massiv_plus[2]);
        int b1_plus = Convert.ToInt32(massiv_plus[3]);
        int b2_plus = Convert.ToInt32(massiv_plus[4]);
        int b3_plus = Convert.ToInt32(massiv_plus[5]);
        int a1_minus = Convert.ToInt32(massiv_minus[0]);
        int a2_minus = Convert.ToInt32(massiv_minus[1]);
        int a3_minus = Convert.ToInt32(massiv_minus[2]);
        int b1_minus = Convert.ToInt32(massiv_minus[3]);
        int b2_minus = Convert.ToInt32(massiv_minus[4]);
        int b3_minus = Convert.ToInt32(massiv_minus[5]);
        if ((Math.Abs(a1_plus + a2_plus + a3_plus) == Math.Abs(b1_plus + b2_plus + b3_plus)) || Math.Abs(a1_minus + a2_minus + a3_minus) == Math.Abs(b1_minus + b2_minus + b3_minus))
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}