Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
Reverse String Using Stack c#
sachith wickramaarachchi
May 7 2016 12:38 PM
797
Reply
How can i reverse a string using stack,here is my code.But there have an error...please help me to fix this problem,thank you :)
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
ConsoleApplication1
{
class
Program
{
int
top;
int
[] stack =
new
int
[100];
public
void
pop()
{
Console.WriteLine(
"{0}"
, stack[top--]);
}
public
void
push(
char
x)
{
if
(top == 100 - 1)
{
Console.WriteLine(
"Stack is overflow"
);
}
else
{
stack[++top] = x;
}
}
public
void
Main()
{
string
word =
"Sri Lanka"
;
int
len = word.Length;
char
[] array = word.ToCharArray();
for
(
int
i = 0; i < len; i++)
{
push(array[i]);
}
for
(
int
i = 0; i < len; i++)
{
pop();
}
}
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
how to solve it?????????????????????????????????????????????
I want to find column name in data table if exist do get the