用户输入7个字符当作密码!然后对其进行加密输出!
加密规则是最后一个字符不变,其它的都加3;
比如:用户输入welcome加密后的字符是:zhofrpe;
class Program
{
static void Main(string[] args)
{
int[] arr = new int[6];
Console.WriteLine("please your six number password");
string pass = Console.ReadLine();
if (arr.Length != pass)
{
Console.WriteLine("Input Error,enter your six number password");
Console.ReadLine();
return;
}
上面是我写的得到用户输入的字符!后面的输入就不会了!麻烦大家告诉我!
加密规则是最后一个字符不变,其它的都加3;
比如:用户输入welcome加密后的字符是:zhofrpe;
class Program
{
static void Main(string[] args)
{
int[] arr = new int[6];
Console.WriteLine("please your six number password");
string pass = Console.ReadLine();
if (arr.Length != pass)
{
Console.WriteLine("Input Error,enter your six number password");
Console.ReadLine();
return;
}
上面是我写的得到用户输入的字符!后面的输入就不会了!麻烦大家告诉我!
for(int i=0;i<cData.Length-1;i++)
{
str+=(char)((int)cData[i] + 3));
}
{
static void Main(string[] args)
{
//打印输出
Console.WriteLine("please your seven number password");
//读用户输入,遇到回车则输入结束
string password = Console.ReadLine();
//如果用户输入的长度不是7,则执行循环,直到输入7,退出循环
while (password.Length != 7)
{
//提示用户需要输入7个字母
Console.WriteLine("Input Error,enter your seven number password");
//重新读取用户输入,回车结尾
password = Console.ReadLine();
}
//因为字符串的索引是只读的,所以,先转换为字符数组
char[] tmp = password.ToCharArray();
for (int i = 0; i < 6; i++)//一共7个字符,循环5次
{
tmp[i] += (char)3;//+3
}
//生成字符串,显示。
Console.WriteLine(new string(tmp));
Console.ReadKey();
}
}
这个回复其实特没意思,楼主你如果希望日后还能有分工作养活自己。最好看懂后,不要再球此类作业题目。
谢谢!原来都是在winfrom中学习的!才开始学习控制台!谢谢你的意见~~