今天做了写C#的习题
题目是:编写一个控制台应用程序,接受用户输入的一个字符串
将其中的字符以与输入相反的顺序输出
怎么把字符以与输入相反的顺序输出来啊?????
我编写的代码只能按顺序输出
请各位大大帮帮忙以下是代码
sing System;
class E2
{
public static void Main(String[] args)
{
Console.WriteLine("Please:");
string x=Console.ReadLine();
char[] y=x.ToCharArray();
Console.WriteLine("you typed {0} character",x.Length);
foreach (char character in x)
{
Console.WriteLine("{0}",character);
}
}
}
先谢了:)
题目是:编写一个控制台应用程序,接受用户输入的一个字符串
将其中的字符以与输入相反的顺序输出
怎么把字符以与输入相反的顺序输出来啊?????
我编写的代码只能按顺序输出
请各位大大帮帮忙以下是代码
sing System;
class E2
{
public static void Main(String[] args)
{
Console.WriteLine("Please:");
string x=Console.ReadLine();
char[] y=x.ToCharArray();
Console.WriteLine("you typed {0} character",x.Length);
foreach (char character in x)
{
Console.WriteLine("{0}",character);
}
}
}
先谢了:)
for (int i=x.length();i>0;i--)
{
Console.WriteLine(x[i]);
}
for(int i=x.Length; i>0; i--)
{
Console.Write("{0}",x[i-1]);
}
s = "abc";
Console.WriteLine(s);
char[] c = s.ToCharArray();
Array.Reverse(c);
s = new string(c);
Console.WriteLine(s);
Console.ReadLine();
{
string str2=str2+str1[i].ToString();
}
输出Str2就可以拉