473,503 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Stacks & Queues

2 New Member
I looked at the old subject again. Link:https://bytes.com/topic/c-sharp/answ...-queue-compare Although I did try, I could not run the code.Is this code capable of working? I want my homework and help.


is it necessary to create a second class?
We have always seen classes as creating a second class.
This is the part that forces me.The assignment is short and I do not have much time.Thank you very much in advance.

Code:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace HW1VY16253601
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Enter in a string");
  14.             string s1 = Console.ReadLine();
  15.             Console.WriteLine(" ");
  16.             Stack<string> st = new Stack<string>();
  17.             Queue<string> q1 = new Queue<string>();
  18.  
  19.  
  20.  
  21.             for (int i = 0; i < s1.Length; i++)
  22.             {
  23.  
  24.                 q1.Enqueue(s1.Substring(i, 1));
  25.                 if (i == s1.Length - 1)
  26.                 {
  27.                     for (i = 0; i < s1.Length; i++)
  28.                     {
  29.                         char y = Convert.ToChar(q1.Dequeue());
  30.                         Console.WriteLine(y);
  31.                     }
  32.                     Console.WriteLine(" ");
  33.                 }
  34.             }
  35.             for (int i = 0; i < s1.Length; i++)
  36.             {
  37.                 st.Push(s1.Substring(i, 1));
  38.                 if (i == s1.Length - 1)
  39.                 {
  40.                     for (i = 0; i < s1.Length; i++)
  41.                     {
  42.                         Char x = Convert.ToChar(st.Pop());
  43.                         Console.WriteLine(x);
  44.                     }
  45.                 }
  46.             }
  47.             string qu = Convert.ToString(q1);
  48.             string sta = Convert.ToString(st);
  49.             if (qu == sta)
  50.             {
  51.                 Console.WriteLine("PALINDROME");
  52.             }
  53.             if (qu != sta)
  54.             {
  55.                 Console.WriteLine("NOT A PALINDROME");
  56.             }
  57.         }
  58.     }
  59. }
Oct 8 '17 #1
2 1876
mtmecaz
2 New Member
Expand|Select|Wrap|Line Numbers
  1. if (qu == sta)
  2. {
  3. Console.WriteLine("PALINDROME");
This is not working. I need to make arrangements for it to work.I expect your answers.
Oct 8 '17 #2
Frinavale
9,735 Recognized Expert Moderator Expert
The Console.WriteLine method works when you are implementing a Console application.

Did you create a Console application project to test this with?

Outside of the obvious "Console.WriteLine" not working...

What are you trying to do?
What type of structures are you expected to use to solve your problem?
Oct 10 '17 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
5011
by: Anand Pillai | last post by:
The standard Python Queue module, allows to generate queues that have no size limit, by passing the size argument as <= 0. q = Queue(0) In a multithreaded application, these queues could be...
3
2268
by: Michael Sparks | last post by:
Hi, I'm posting a link to this since I hope it's of interest to people here :) I've written up the talk I gave at ACCU Python UK on the Kamaelia Framework, and it's been published as a BBC...
4
3192
by: Ice | last post by:
Hi there, I'm not sure if this is the right group for this- If it isn't, could anyone point me in the right direction? For our data structures exam, we are usually asked to implement the...
7
2350
by: GrandpaB | last post by:
While writing this plea for help, I think I solved my dilemma, but I don't know why the statement that solved the problem is necessary. The inspiration for the statement came from an undocumented...
10
2108
by: Rich Kucera | last post by:
Holding all versions at 5.0.4, Multiple stacks with multiple-version configurations inevitable Will have to wait to see what the impact of problems such as http://bugs.php.net/bug.php?id=33643 ...
1
1481
by: romel | last post by:
Hi to all evryone? Anyone can help me regarding the program that i have?...i got problems about our topic that all about the QUEUE & STACKS.... I am begging you all that send...
5
10748
by: ravi | last post by:
Can any body tell me How to implement a stack using two queues Thax in advance
0
1052
by: phanipep | last post by:
4 applications of stacks and queues. Justify your choices.
11
5896
mia023
by: mia023 | last post by:
Hello everyone. Assume that we have previously defined the following class StockPurchase that has the following as instance variables a) The name of the stock (a string) b) The number of...
0
7192
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7315
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5559
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1492
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.