class Program
{
static void Main(string[] args)
{
chongfu:
jiami();
//jiemi();
Console.ReadKey();
goto chongfu;
}
public static void jiami()
{
Console.WriteLine("请输入4位数:");
int num = Convert.ToInt32(Console.ReadLine());
//if (num >= 1000 && num < 10000)
//{
int qianwei = num / 1000;//千位;
int baiwei = num / 100 % 10;//百位;
int shiwei = num / 10 % 10;//十位;
int gewei = num % 10;//个位;
qianwei = (qianwei + 5) % 10;
baiwei = (baiwei + 5) % 10;
shiwei = (shiwei + 5) % 10;
gewei = (gewei + 5) % 10;
string str = "";
str = "" + gewei + shiwei + baiwei + qianwei;//前面加字符串符号“”;不能后面加,否则就运算;
Console.WriteLine("加密数字为:{0}\n", str);
int num1 = Convert.ToInt32(str);
// Console.WriteLine(num1);
qianwei = num1 / 1000;//千位;
baiwei = num1 / 100 % 10;//百位;
shiwei = num1 / 10 % 10;//十位;
gewei = num1 % 10;//个位
if (qianwei >= 5)
{
qianwei = (qianwei - 5);
}
else
{
qianwei = (5 + qianwei);
}
if (baiwei >= 5)
{
baiwei = (baiwei - 5);
}
else
{
baiwei = (5 + baiwei);
}
if (shiwei >= 5)
{
shiwei = (shiwei - 5);
}
else
{
shiwei = (5 + shiwei);
}
if (gewei >= 5)
{
gewei = (gewei - 5);
}
else
{
gewei = (5 + gewei);
}
str = "" + gewei + shiwei + baiwei + qianwei;
Console.WriteLine("解密数字为:{0}\n", str);
}
}
unity游戏开发-C#语言基础篇(加密数字及解密数字)
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...