PDA

View Full Version : مشکل این برنامه چیه؟



parhamm
شنبه 24 تیر 1391, 13:47 عصر
سلام به همه
من می خوام برنامه ای بنویسم که یه عدد می گیره بعد برعکسش می کنه اگر عدد با برعکسش برابر بود چاپ کنه yes
در غیر این صورت چاپ کنه no
ولی نمی دونم مشکل این برنامه کجاست
لطفا کمکم کنید


using


System;

using



System.Collections.Generic;

using



System.ComponentModel;

using



System.Data;

using



System.Drawing;

using



System.Text;

using



System.Windows.Forms;

namespace



WindowsApplication1

{


publicpartialclassForm1 : Form

{


public Form1()

{

InitializeComponent();

}


privatevoid button1_Click(object sender, EventArgs e)

{




int z=1, a, s=1;


double w=0, i, k;

a =
int.Parse(textBox1.Text);


while (z != 0)

{

z = a / 10;

a = z;

w++;

}

a =
int.Parse(textBox1.Text);


for (i = w; i >= 1; i++)

{

z = a % 10;

s = a / 10;

a = s;

w--;

k = k +
Math.Pow(10, w) * z;

}

a =
int.Parse(textBox1.Text);


if (a == k) label2.Text = "yes";


else label2.Text = "no";

}

}

}

tooraj_azizi_1035
شنبه 24 تیر 1391, 14:17 عصر
سلام
اگه کدت رو اینطوری بنویسی ایرادی داره؟


char[] arr = s.ToCharArray();
string num=Array.Reverse(arr);
if(String.Compare (s,num)==0);
"yes"
else
"no"