(C#)将用户输入的字符串相反输出
staticvoidMain(string[]args) { //接收用户输入的字符串,将其中的字符以与输入相反的顺序输出。 Console.WriteLine("Givemeastring:"); stringmystring=Console.ReadLine(); stringmyresult=""; for(inti=mystring.Length-1;i>=0;i--) { myresult+=mystring[i];//或者myresult+=mystring.Substring(i,1); } Console.WriteLine("Theresultis{0}:",myresult); Console.ReadKey(); }
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。