Advertisement
XfreeBG

Untitled

Oct 18th, 2022
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Program
  6. {
  7.     public static void Main()
  8.     {
  9.         string input = Console.ReadLine();
  10.         List<string> inputs = input.Split(' ').ToList();
  11.         List<string> orderedInput = new List<string>();
  12.         if (inputs[0].Contains("x^2"))
  13.         {
  14.             if(inputs[0][0] == '-')
  15.             {
  16.                 orderedInput.Add("-");
  17.                 inputs[0] = inputs[0].Replace("-", "");
  18.             }
  19.             else
  20.             {
  21.                 orderedInput.Add("+");
  22.             }
  23.             orderedInput.Add(inputs[0]);
  24.         }
  25.         else if (inputs[2].Contains("x^2"))
  26.         {
  27.             orderedInput.Add(inputs[1]);
  28.             orderedInput.Add(inputs[2]);
  29.         }
  30.         else if (inputs[4].Contains("x^2"))
  31.         {
  32.             orderedInput.Add(inputs[3]);
  33.             orderedInput.Add(inputs[4]);
  34.         }
  35.  
  36.  
  37.         if (inputs[0].Contains("x") && !inputs[0].Contains("x^2"))
  38.         {
  39.             Console.WriteLine("ddz");
  40.             if (inputs[0][0] == '-')
  41.             {
  42.                 orderedInput.Add("-");
  43.                 inputs[0] = inputs[0].Replace("-", "");
  44.             }
  45.             else
  46.             {
  47.                 orderedInput.Add("+");
  48.             }
  49.             orderedInput.Add(inputs[0]);
  50.         }
  51.         else if (inputs[2].Contains("x") && !inputs[0].Contains("x^2"))
  52.         {
  53.             Console.WriteLine("ddz");
  54.             orderedInput.Add(inputs[1]);
  55.             orderedInput.Add(inputs[2]);
  56.         }
  57.         else if (inputs[4].Contains("x") && inputs[0].Contains("x^2") == false)
  58.         {
  59.             Console.WriteLine("ddz");
  60.             orderedInput.Add(inputs[3]);
  61.             orderedInput.Add(inputs[4]);
  62.         }
  63.  
  64.  
  65.         if (int.TryParse(inputs[0], out int result0) == true)
  66.         {
  67.             if (inputs[0][0] == '-')
  68.             {
  69.                 orderedInput.Add("-");
  70.                 inputs[0] = inputs[0].Replace("-", "");
  71.             }
  72.             else
  73.             {
  74.                 orderedInput.Add("+");
  75.             }
  76.             orderedInput.Add(inputs[0]);
  77.         }
  78.         else if (int.TryParse(inputs[2], out int result2) == true)
  79.         {
  80.             orderedInput.Add(inputs[1]);
  81.             orderedInput.Add(inputs[2]);
  82.         }
  83.         else if(int.TryParse(inputs[4], out int result4) == true)
  84.         {
  85.             orderedInput.Add(inputs[3]);
  86.             orderedInput.Add(inputs[4]);
  87.  
  88.         }
  89.         //Console.WriteLine(orderedInput[0] + " " + orderedInput[1] + " " + orderedInput[2] + " " + orderedInput[3] + " " + orderedInput[4] + " " + orderedInput[5]);
  90.  
  91.  
  92.     }
  93. }
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement