Sample Code1:
public partial class Palindram : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string s1 = "sandhya nettam";
stringex s2 = new stringex();
bool b = s2.Ispalindrom(s1);
if (b == true)
{
Response.Write(s1 + " is a palindrom");
}
else
{
Response.Write(s1 + "is not pollindrome");
}
}
}
public class stringex
{
public bool Ispalindrom(string s1)
{
bool b=false;
for(int i=0,j=s1.Length-1;i<s1.Length;i++,j--)
{
if (s1[i] == s1[j])
{
b = true;
continue;
}
else
b = false;
}
return b;
}
}
{
protected void Page_Load(object sender, EventArgs e)
{
string s1 = "sandhya nettam";
stringex s2 = new stringex();
bool b = s2.Ispalindrom(s1);
if (b == true)
{
Response.Write(s1 + " is a palindrom");
}
else
{
Response.Write(s1 + "is not pollindrome");
}
}
}
public class stringex
{
public bool Ispalindrom(string s1)
{
bool b=false;
for(int i=0,j=s1.Length-1;i<s1.Length;i++,j--)
{
if (s1[i] == s1[j])
{
b = true;
continue;
}
else
b = false;
}
return b;
}
}
sample code2:
{
string s1="mam";
stringex s=new stringex();bool b1=s.Ispalindrom(s1);
If(b1==true)
{
Response.Write("s1 is not finit no.");
}
}
}
public class stringex
{
public bool Ispalindrom(string s1)
{
bool b=false;
for(int i=0; j=(s1.length-1; i<s1.length; i++,j++)
{
if(s1[i]==s1[j])
{
b=true;
continue;
}
else
break;
}
return b;
}
}
No comments:
Post a Comment