更新时间:2023-02-11 18:02:37
您要做的是将某个字符分割成字符串,在您的情况下,将其分隔为-"并保存将其放入数组并进行数组计数,请以您的反向方法传递每个元素..
例如.
What you have to do is split string for some character, in your case, its ''-'' and save it in array and for array count, pass each element in your reverse method..
For eg.
string s = "101-102-103-104-105";
string[] numbers= s.Split('-');
foreach (string num in numbers )
{
int a = Convert.ToInt16(num);
int result=0;
do
{
result = (result * 10) + (a% 10);
a= a/ 10;
}while (a> 0);
Console.WriteLine(result);
}
由于这是一个逻辑问题,我请您自己解决.您可以解决它,因为您可以解决一个问题.我给您一个窍门,将这个数字逻辑应用于3位数字的每个数字.只有当它为0时才需要对其进行自定义,否则在每种情况下都是相同的.您可以使用循环来做到这一点.
好吧,如果您尝试失败,那就看看吧.
http://wiki.answers.com/Q/Write_a_program_in_c_language_to_reverse_a_three_digit_with_ <.com _ blank new window> ^ ]
As it is a logical problem i refer you to do it by yourself.you can solve it as you can do it for one number.i give you one trick,apply this one number logic to every number of a 3 digit number.only you need to customize it when it is 0 otherwise for every case it is same.You can use loop to do it.
Ok,if you fail in your try then see it..
http://wiki.answers.com/Q/Write_a_program_in_c_language_to_reverse_a_three_digit_integer_number_without_using_loops[^]
我找到了解决方案:D,但我没有从字符串中使用方法:D
我想要这个代码....
I found solution :D and i don''t use from string method :D
I want This code....
{
int a = Convert.ToInt16(txt1.Text), b = Convert.ToInt16(txt2.Text);
int r = 0,s=0;
lblshow.Text = null;
for (int i = a; i <= b; i++)
{
s = i;
while (s > 10)
{
r = r * 10 + (s % 10);
s = s / 10;
}
r = r * 10 + (s % 10);
lblshow.Text += r + " , ";
r = 0;
}
}