输入一个正整数,按照逆序显示输出各位数字。例如:输入2389,则输出为9832”可是我调试的时候他说我的d没赋

这是我的代码,我是初学者,麻烦帮我看看。
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication48
{
class Program
{
static void Main(string[] args)
{
int i,j,k,h,s,d;
Console.WriteLine("请输入一个四位整数。");
i = int.Parse(Console.ReadLine());
for (j = 1; j <= 9; j++)
{
for (k = 1; k <= 9; k++)
{
for (h = 1; h <= 9; h++)
{
for (s = 1; s <= 9; s++)
{
if (j * 1000 + k * 100 + h * 10 + s == i)
d = s * 1000 + h * 100 + k * 10 + j;
Console.WriteLine("经过逆序后的整数为{0}",d);
}
}
}
}

}
}
}
我就是放在循环不行,才放到里面的,可是还是不行!!!!!

第1个回答  2008-07-04
Console.WriteLine("经过逆序后的整数为{0}",d);
这一句移到循环外面
相似回答
大家正在搜