看别人帖子,才发现的,挺有趣的,分享下
public class Program
{public static void Main(String[] args)
{
int[] arr = new int[] { 2, 7, 3, 5, 6, 0, 9, 8 };
int[] index = new int[] { 2, 5, 3, 1, 3, 0, 5, 4, 3 };
String q = "";
for (int i = 0; i < index.Length; i++)
{
q += arr[index[i]];
}
Console.WriteLine("得到的QQ号为:{0}", q);
int[] a = new int[] { 7, 3, 1, 0, 5, 9 };
int[] b = new int[] { 2, 4, 2, 1, 4, 4, 0, 5, 0, 2, 4 };
String tel = "";
for (int j = 0; j < b.Length; j++)
{
tel += a[b[j]];
}
Console.WriteLine("得到的手机号为:{0}", tel);
Console.Read();
}
}
本文分享了两个使用C#进行数组操作的例子,包括通过索引构建字符串来模拟QQ号和电话号码的生成过程,展示了如何遍历数组并根据另一个数组中的索引获取元素。
3180

被折叠的 条评论
为什么被折叠?



