Mã: //Nhap vao ten sinh vien: //xuat ra ho, ten //dem ten co bao nhieu tu //in nguoc ten ra man hinh using System; using System.Collections.Generic; using System.Text; namespace Chuoi { class Program { static void Main(string[] args) { //tao string sv1 de nhap ten sv vao string sv1; Console.WriteLine("Moi nhap ho ten sinh vien: "); sv1 = Console.ReadLine(); //lay do dai cua chuoi ten sinh vien vua nhap int n= sv1.Length; //ta Ho cua sinh vien duoc ket thuc bang khoang trang //vi vay dem do dai cua Ho tu` dau` den khoang trang gan nhat int x = sv1.IndexOf(" "); //ta thay Ten cua sinh vien la ky tu cuoi cung, phan //biet voi cac ky tu khac bang khoang trang cuoi cung //nen dung ham lastindexof de dem so ky tu tu dau den het khoang trang cuoi cung // roi lay do dai cua chuoi tru cho gia tri lastindexof se ra do dai cua ten int y = sv1.LastIndexOf(" "); //tach ten o vi tri y (khoang trang cuoi cung ) voi do dai la n-y (do dai cua ten) string ten = sv1.Substring(y, n - y); //tach ho o vi tri dau tien voi do dai la x (do dai cua ho) string ho = sv1.Substring(0, x); //tach tung tu trong ho ten sinh vien va dua vao mang char dau = char.Parse(" "); string[] mang1 = new string[100]; mang1 = sv1.Split(dau); //dem so ky tu cua mang int dodai = mang1.Length; //xuat ten, ho, dem so tu Console.WriteLine("Ten: {0}",ten); Console.WriteLine("Ho: {0}", ho); Console.WriteLine("Tong so tu la: {0}",dodai); //xuat nguoc for (int i = dodai -1; i >= 0; i--) Console.WriteLine(mang1[i]); Console.ReadLine(); } } }