求高手解答c#程序

来源:百度知道 编辑:UC知道 时间:2024/05/24 18:08:32
假设有一段程序对字符串进行加密,加密后的字符串的第一个字符事原字符串的最后一个字符,
其余的每个字符是原字符串的前一个字符的值加上3。比如"welcome",末尾的字符为"e",
"welcom"依此加上3后为"zhofrp",故加密后的结果为"ezhofrp"。程序由用户输入一个字符串,加密后输出

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

namespace practice
{
class Program
{
static void Main(string[] args)
{
string PutIn=Console.ReadLine();
char[] arr=PutIn .ToCharArray();
char[] arr2=new char[arr .Length ];
arr2[0] = Convert.ToChar(Convert.ToInt32(arr[arr.Length-1 ] + 3));
for (int i = 0; i < PutIn.Length - 1; i++)
arr2[i + 1] = Convert.ToChar(Convert .ToInt32 (arr[i]+3));
Console.WriteLine(new string(arr2));
Console.ReadKey ();
}
}
}

String s="welcome";
char[] cs=s.ToCharArray();
char[] cs2=new char[cs.Length];
cs2[0]=cs[cs.Length-1];
for(int i=0;i<cs.Length-1;i++)
cs2[i+1]=Convert.ToChar(Convert.ToInt32(cs[i])+3);
MessageBox.S