首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

华智公司一路面试题

2012-07-25 
华智公司一道面试题??? //说明:例如:??? //数字123-变成00000123??? //123456789-变成23456789??? class

华智公司一道面试题

??? //说明:例如:
??? //数字123->变成00000123
??? //123456789->变成23456789
??? class Program
??? {
??????? static void Main(string[] args)
??????? {
??????????? //用户随便输入一个字符串
??????????? string s = Console.ReadLine();
??????????? //长度大于8
??????????? if (s.Length>=8)
??????????? {
??????????????? s = s.Substring(s.Length - 8, 8);
??????????? }
??????????
??????????? //小于8的长度
??????????? else if (s.Length < 8)
??????????? {
??????????????? string adds=null;
??????????????? for (int i = 0; i < 8-s.Length; i++)
??????????????? {
??????????????????? adds += "0";
??????????????? }
??????????????? s = adds +? s;
??????????? }

??????????? Console.WriteLine(s);
??????????? Console.ReadKey();
??????? }

热点排行