c语言12345变成54321??

2024-11-18 22:41:54
推荐回答(1个)
回答1:

using System;
using System.Collections.Generic;
using System.Text;

namespace myperoject512
{
class Program
{
static void Main(string[] args)
{
int i = 12345, j = 0;
string stemp = "";
string temp = i.ToString();
char[] ctemp = temp.ToCharArray();
for (int z = ctemp.Length - 1; z >= 0; z--)
{
stemp = stemp + ctemp[z];
}
Console.WriteLine("{0}", stemp);
Console.ReadKey();
i = Convert.ToInt32(stemp);
Console.WriteLine("{0}", i);
Console.ReadKey();

}
}
}
这个是 c#的代码
思路就是把int i=12345 转换成char 或者string的数组 然后倒序 再转换成int