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
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace HW1VY16253601
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Enter in a string");
- string s1 = Console.ReadLine();
- Console.WriteLine(" ");
- Stack<string> st = new Stack<string>();
- Queue<string> q1 = new Queue<string>();
- for (int i = 0; i < s1.Length; i++)
- {
- q1.Enqueue(s1.Substring(i, 1));
- if (i == s1.Length - 1)
- {
- for (i = 0; i < s1.Length; i++)
- {
- char y = Convert.ToChar(q1.Dequeue());
- Console.WriteLine(y);
- }
- Console.WriteLine(" ");
- }
- }
- for (int i = 0; i < s1.Length; i++)
- {
- st.Push(s1.Substring(i, 1));
- if (i == s1.Length - 1)
- {
- for (i = 0; i < s1.Length; i++)
- {
- Char x = Convert.ToChar(st.Pop());
- Console.WriteLine(x);
- }
- }
- }
- string qu = Convert.ToString(q1);
- string sta = Convert.ToString(st);
- if (qu == sta)
- {
- Console.WriteLine("PALINDROME");
- }
- if (qu != sta)
- {
- Console.WriteLine("NOT A PALINDROME");
- }
- }
- }
- }