avishy
avishy
CC#
Created by avishy on 5/21/2024 in #help
Queue and Node question
public static bool EqualSums(Queue<int> q) { int first = q.Remove(); int last = RemoveLast(q); int sum = first + last; Queue<int> c = q; for(int i = 0; i < Length(q)/2; i++) { if(q.Remove() + RemoveLast(q) != sum) { return false; } } if(!q.IsEmpty() && q.Remove() != sum) { return false; } return true; } public static void RemoveEqualSums(Node<Queue<int>> lst) { Node<Queue<int>> curr = lst; if (EqualSums(curr.GetValue()) == false) { curr.SetNext(null); } while (curr.GetNext() != null) { if(EqualSums(curr.GetNext().GetValue()) ==false) { curr.SetNext(curr.GetNext().GetNext()); curr.GetNext().SetNext(null); } curr = curr.GetNext();
} } why is this code incorrect? please help
2 replies
CC#
Created by avishy on 11/11/2023 in #help
trying to create a function that returns the list from even numbers to odd numbers
public static Node<int> EvenOdd(Node<int> head)
{
Node<int> curr = head;
Node<int> newNode = new Node<int>(GetLength(head));


while (curr != null)
{
if (curr.GetValue() % 2 == 0)
{
if (newNode == null)
{
newNode = curr;
}
else { newNode.SetNext(curr) ; }
}
curr = curr.GetNext();
}
Node<int> curre = head;
while (curre != null)
{
if (curre.GetValue() % 2 != 0)
{
newNode.SetNext(curre);
}
curre = curre.GetNext();
}

return newNode;
}
public static Node<int> EvenOdd(Node<int> head)
{
Node<int> curr = head;
Node<int> newNode = new Node<int>(GetLength(head));


while (curr != null)
{
if (curr.GetValue() % 2 == 0)
{
if (newNode == null)
{
newNode = curr;
}
else { newNode.SetNext(curr) ; }
}
curr = curr.GetNext();
}
Node<int> curre = head;
while (curre != null)
{
if (curre.GetValue() % 2 != 0)
{
newNode.SetNext(curre);
}
curre = curre.GetNext();
}

return newNode;
}
2 replies
CC#
Created by avishy on 11/11/2023 in #help
trying to create a function that returns the list from even numbers to odd numbers, please help
public static Node<int> EvenOdd(Node<int> head)
{
Node<int> curr = head;
Node<int> newNode = new Node<int>(GetLength(head));


while (curr != null)
{
if (curr.GetValue() % 2 == 0)
{
if (newNode == null)
{
newNode = curr;
}
else { newNode.SetNext(curr) ; }
}
curr = curr.GetNext();
}
Node<int> curre = head;
while (curre != null)
{
if (curre.GetValue() % 2 != 0)
{
newNode.SetNext(curre);
}
curre = curre.GetNext();
}

return newNode;
}
public static Node<int> EvenOdd(Node<int> head)
{
Node<int> curr = head;
Node<int> newNode = new Node<int>(GetLength(head));


while (curr != null)
{
if (curr.GetValue() % 2 == 0)
{
if (newNode == null)
{
newNode = curr;
}
else { newNode.SetNext(curr) ; }
}
curr = curr.GetNext();
}
Node<int> curre = head;
while (curre != null)
{
if (curre.GetValue() % 2 != 0)
{
newNode.SetNext(curre);
}
curre = curre.GetNext();
}

return newNode;
}
9 replies
CC#
Created by avishy on 2/14/2023 in #help
I built a rock paper scissors game but it always returns a draw. can anyone help me?
providing code here👇
112 replies
CC#
Created by avishy on 2/11/2023 in #help
Hi im not sure that my code is working as it should(class in c sharp)
providing code here👇(When i add +1 or +10 to the GetX or GetY isn't it supossed to change?)
54 replies
CC#
Created by avishy on 2/11/2023 in #help
Hi i need some help with classes, im pretty new to this and i have an error with my code.
help would be appreciated(in csharp)
63 replies
CC#
Created by avishy on 2/9/2023 in #help
Hi I’m building in C sharp a very very rock paper scissors game using classes
I want the result to look cooler please help me if you can if very much appreciate it
12 replies