عدد متقارن
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace adade_maghlob
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public int maghlob(string x,int l,int h)
{
if(l>=h)
return(1);
else
{
if(x[l]==x[h])
return(maghlob(x,l+1,h-1));
else
return(-1);
}
}
private void button1_Click(object sender, EventArgs e)
{
int l=0;
string s = (maghlob(textBox1.Text,l,h-1)).ToString();
MessageBox.Show( s,"1 is true & -1 is false");
}
public int h;
private void textBox1_TextChanged(object sender, EventArgs e)
{
h = textBox1.Text.Length;
}
}
}