simasim 5 Точки

Здравейте, бих била много благодарна, ако някой види защо в тази задача във вижуъл студио всичко излиза, както е по условието, а в джъдж ми дава 50 точки.

Става дума за последната задача от лаба за листове.

Ето кода:

https://pastebin.com/88YRTw7K?fbclid=IwAR2wHdBRPusrybwTy5hgxe9DNvtf08uG7C0eaiMgkWafRoaYAcWn1e_BeKU

Ето и условието:

Next, we are going to implement more complicated list commands, extending the previous task. Again, read a list
Contains {number} – check if the list contains the number and if so - print &quot;Yes&quot;, otherwise print &quot;No such number&quot;.
PrintEven – print all the even numbers, separated by a space.
PrintOdd – print all the odd numbers, separated by a space.
GetSum – print the sum of all the numbers.
Filter {condition} {number} – print all the numbers that fulfill the given condition. The condition will be either &#39;&lt;&#39;,
&#39;&gt;&#39;, &quot;&gt;=&quot;, &quot;&lt;=&quot;.
After the end command, print the list only if you have made some changes to the original list. Changes are made
only from the commands from the previous task.

Тагове:
0
koknq 22 Точки

using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp26
{
class Program
{
static void Main(string[] args)
{
.Split(' ')
.Select(int.Parse)
.ToList();
bool change = false;
while (true)
{
if (command == "end")
{
break;
}
string[] tokens = command.Split(' ');
switch (tokens[0])
{
int number = int.Parse(tokens[1]);
case "Remove":
int number1 = int.Parse(tokens[1]);
numbers.Remove(number1);  change = true; break;
case "RemoveAt":
int number2 = int.Parse(tokens[1]);
numbers.RemoveAt(number2);  change = true; break;
case "Insert":
int number3 = int.Parse(tokens[1]);
int number4 = int.Parse(tokens[2]);
numbers.Insert(number4, number3);  change = true; break;
case "Contains":
int numberC = int.Parse(tokens[1]);
if (numbers.Contains(numberC))
{
Console.WriteLine("Yes");
}
else
{
Console.WriteLine("No such number");
}
break;
case "PrintEven":
List<int> even = new List<int>();
for (int i = 0; i < numbers.Count; i++)
{
if (numbers[i] % 2 == 0)
{
}
}
Console.WriteLine(string.Join(" ", even));
break;
case "PrintOdd":
List<int> odd = new List<int>();
for (int i = 0; i < numbers.Count; i++)
{
if (numbers[i] % 2 != 0)
{
}
}
Console.WriteLine(string.Join(" ", odd));
break;
case "GetSum":
int sum = 0;
for (int i = 0; i < numbers.Count; i++)
{
sum += numbers[i];
}
Console.WriteLine(sum);
break;
case "Filter":
string sign = tokens[1]; int numberF = int.Parse(tokens[2]);
if (sign == ">")
{
List<int> nov = new List<int>();
for (int i = 0; i < numbers.Count; i++)
{
if (numbers[i] > numberF)
{
}
}
Console.WriteLine(String.Join(" ", nov));
}
else if (sign == "<")
{
List<int> nov = new List<int>();
for (int i = 0; i < numbers.Count; i++)
{
if (numbers[i] < numberF)
{
}
}
Console.WriteLine(String.Join(" ", nov));
}
else if (sign == "<=")
{
List<int> nov = new List<int>();
for (int i = 0; i < numbers.Count; i++)
{
if (numbers[i] <= numberF)
{
}
}
Console.WriteLine(String.Join(" ", nov));
}
else if (sign == ">=")
{
List<int> nov = new List<int>();
for (int i = 0; i < numbers.Count; i++)
{
if (numbers[i] >= numberF)
{
}
}
Console.WriteLine(String.Join(" ", nov));
}
break;

}
}
if (change == true)
{
Console.WriteLine(string.Join(" ", numbers));
}
}
}
}

100/100 judge :D

0
bobby24 2 Точки

Някой ще ми погледне ли кода, моля.

https://pastebin.com/v9BJgSBR

Дава ми 90/100 и грешка на 5-я тест в Judge - Test #5 (Runtime error). Моят код е по-прост - без да създавам нови списъци.

0
20/10/2021 16:23:15