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

微软面试题目,小弟我同学去面试了,手机拍的,分享一下

2014-01-14 
微软面试题目,我同学去面试了,手机拍的,分享一下!我同学到上海微软分公司去面试了,一道考题,题目如下:微软

微软面试题目,我同学去面试了,手机拍的,分享一下!
我同学到上海微软分公司去面试了,一道考题,题目如下:
微软销售部招聘在线销售人员11名,三个月的业绩考核期,业绩考核分为销售业绩考核和工作激情度考核。销售业绩单位为套,工作激情度单位为分。三个月后,11个人的考核信息分别如下:
A01 198件 97分
A02 90件  103分
A02 76件  78分
A03 123件 100分
A04 77件  87分
A05 10件  54分
A06 81件  104分
A07 110件 87分
A08 45件  41分
A09 123件 99分
A10 140件 88分
A11 109件 98分
要求:
如果销售业绩高于总的平均件数N的销售人员将被留下,低于平均件数N的销售人员将被淘汰。请使用C++/C#编程实现:按照销售业绩从大到小的顺序输出被留下人员的编号信息,销售信息,工作激情度信息。
兄弟们看看,我同学手机拍的,拿回来考我,感觉很简单,但是又无从下手!微软面试题目,小弟我同学去面试了,手机拍的,分享一下


[解决办法]


    class Program
    {
        static void Main(string[] args)
        {
            List<Sales> lsales = new List<Sales>()
            {
               new Sales{Num="A01",Performance=198,Score=97},
               new Sales{Num="A02",Performance=90,Score=103},
               new Sales{Num="A03",Performance=76,Score=78},
               new Sales{Num="A04",Performance=123,Score=100},
               new Sales{Num="A05",Performance=77,Score=87},
               new Sales{Num="A06",Performance=10,Score=54},
               new Sales{Num="A07",Performance=81,Score=107},
               new Sales{Num="A08",Performance=110,Score=87},
               new Sales{Num="A09",Performance=45,Score=41},
               new Sales{Num="A10",Performance=123,Score=99},
               new Sales{Num="A11",Performance=140,Score=88}
            };
            List<Sales> odsales = new List<Sales>();
            foreach (Sales sales in lsales)
            {
                if (sales.Performance > lsales.Average(s => s.Performance))
                    odsales.Add(sales);
            }
            odsales.Sort(new performanceCompare());
            Console.WriteLine("嗨,留下来:");
            foreach (Sales sl in odsales)
            {
                Console.WriteLine(sl.Num + " " + sl.Performance + " " + sl.Score);
            }
            Console.ReadLine();
        }
    }
    class Sales
    {
        string num;

        public string Num
        {
            get { return num; }
            set { num = value; }


        }
        int performance;

        public int Performance
        {
            get { return performance; }
            set { performance = value; }
        }
        int score;

        public int Score
        {
            get { return score; }
            set { score = value; }
        }
    }
    class performanceCompare : IComparer<Sales> 
    { 
        public int Compare(Sales a, Sales b) 
        { 
            return a.Performance.CompareTo(b.Performance);
        }
    } 



没仔细看,随便写两句  抛砖引玉。 也不知道对错, 垃圾码龙  求打击
[解决办法]
借用楼上的代码,修改一下
class Program
{
    static void Main(string[] args)
    {
        List<Sales> lsales = new List<Sales>()
        {
            new Sales{Num="A01",Performance=198,Score=97},
            new Sales{Num="A02",Performance=90,Score=103},
            new Sales{Num="A03",Performance=76,Score=78},
            new Sales{Num="A04",Performance=123,Score=100},
            new Sales{Num="A05",Performance=77,Score=87},
            new Sales{Num="A06",Performance=10,Score=54},
            new Sales{Num="A07",Performance=81,Score=107},
            new Sales{Num="A08",Performance=110,Score=87},
            new Sales{Num="A09",Performance=45,Score=41},
            new Sales{Num="A10",Performance=123,Score=99},
            new Sales{Num="A11",Performance=140,Score=88}
        };
        var avr = lsales.Average(s => s.Performance);
        foreach (var sl in from s in lsales
                            where s.Performance > avr
                            orderby s.Performance descending
                            select s)
        {
            Console.WriteLine(sl.Num + " " + sl.Performance + " " + sl.Score);
        }
        Console.ReadLine();

    }

}

class Sales
{
    string num;

    public string Num
    {
        get { return num; }
        set { num = value; }
    }
    int performance;

    public int Performance
    {
        get { return performance; }
        set { performance = value; }
    }
    int score;

    public int Score
    {
        get { return score; }
        set { score = value; }
    }


}


[解决办法]
引用:
借用楼上的代码,修改一下
class Program
{
    static void Main(string[] args)
    {
        List<Sales> lsales = new List<Sales>()
        {
            new Sales{Num="A01",Performance=198,Score=97},
            new Sales{Num="A02",Performance=90,Score=103},
            new Sales{Num="A03",Performance=76,Score=78},
            new Sales{Num="A04",Performance=123,Score=100},
            new Sales{Num="A05",Performance=77,Score=87},
            new Sales{Num="A06",Performance=10,Score=54},
            new Sales{Num="A07",Performance=81,Score=107},
            new Sales{Num="A08",Performance=110,Score=87},
            new Sales{Num="A09",Performance=45,Score=41},
            new Sales{Num="A10",Performance=123,Score=99},
            new Sales{Num="A11",Performance=140,Score=88}
        };
        var avr = lsales.Average(s => s.Performance);
        foreach (var sl in from s in lsales
                            where s.Performance > avr
                            orderby s.Performance descending
                            select s)
        {
            Console.WriteLine(sl.Num + " " + sl.Performance + " " + sl.Score);
        }
        Console.ReadLine();

    }

}

class Sales
{
    string num;

    public string Num
    {
        get { return num; }
        set { num = value; }
    }
    int performance;

    public int Performance
    {
        get { return performance; }
        set { performance = value; }
    }
    int score;

    public int Score
    {
        get { return score; }
        set { score = value; }
    }
}


这就是真正的程序员跟我这样的垃圾的区别了,楼主可以结贴了。
[解决办法]
呵,上面的num可以输入null或""
performance和score可以接受负数。。。
[解决办法]
引用:
Quote: 引用:

借用楼上的代码,修改一下
class Program
{
    static void Main(string[] args)
    {
        List<Sales> lsales = new List<Sales>()
        {
            new Sales{Num="A01",Performance=198,Score=97},
            new Sales{Num="A02",Performance=90,Score=103},
            new Sales{Num="A03",Performance=76,Score=78},
            new Sales{Num="A04",Performance=123,Score=100},
            new Sales{Num="A05",Performance=77,Score=87},
            new Sales{Num="A06",Performance=10,Score=54},
            new Sales{Num="A07",Performance=81,Score=107},
            new Sales{Num="A08",Performance=110,Score=87},


            new Sales{Num="A09",Performance=45,Score=41},
            new Sales{Num="A10",Performance=123,Score=99},
            new Sales{Num="A11",Performance=140,Score=88}
        };
        var avr = lsales.Average(s => s.Performance);
        foreach (var sl in from s in lsales
                            where s.Performance > avr
                            orderby s.Performance descending
                            select s)
        {
            Console.WriteLine(sl.Num + " " + sl.Performance + " " + sl.Score);
        }
        Console.ReadLine();

    }

}

class Sales
{
    string num;

    public string Num
    {
        get { return num; }
        set { num = value; }
    }
    int performance;

    public int Performance
    {
        get { return performance; }
        set { performance = value; }
    }
    int score;

    public int Score
    {
        get { return score; }
        set { score = value; }
    }
}


var avr = lsales.Average(s => s.Performance);
        foreach (var sl in from s in lsales
                            where s.Performance > avr
                            orderby s.Performance descending
                            select s)
        {
            Console.WriteLine(sl.Num + " " + sl.Performance + " " + sl.Score);
        }
后面没看懂、求大神备注


http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b/

这个资料还是很好的,可以参考下~~
[解决办法]
引用:
借用楼上的代码,修改一下
class Program
{
    static void Main(string[] args)
    {
        List<Sales> lsales = new List<Sales>()
        {
            new Sales{Num="A01",Performance=198,Score=97},
            new Sales{Num="A02",Performance=90,Score=103},
            new Sales{Num="A03",Performance=76,Score=78},
            new Sales{Num="A04",Performance=123,Score=100},
            new Sales{Num="A05",Performance=77,Score=87},
            new Sales{Num="A06",Performance=10,Score=54},
            new Sales{Num="A07",Performance=81,Score=107},
            new Sales{Num="A08",Performance=110,Score=87},
            new Sales{Num="A09",Performance=45,Score=41},
            new Sales{Num="A10",Performance=123,Score=99},
            new Sales{Num="A11",Performance=140,Score=88}


        };
        var avr = lsales.Average(s => s.Performance);
        foreach (var sl in from s in lsales
                            where s.Performance > avr
                            orderby s.Performance descending
                            select s)
        {
            Console.WriteLine(sl.Num + " " + sl.Performance + " " + sl.Score);
        }
        Console.ReadLine();

    }

}

class Sales
{
    string num;

    public string Num
    {
        get { return num; }
        set { num = value; }
    }
    int performance;

    public int Performance
    {
        get { return performance; }
        set { performance = value; }
    }
    int score;

    public int Score
    {
        get { return score; }
        set { score = value; }
    }
}



            var avr = lsales.Average(a=>a.Performance);
            foreach (Sales item in lsales.Where(s => s.Performance > avr).OrderByDescending(s=>s.Performance))
            {
                MessageBox.Show(item.Num);
            }
我还是觉得我这个看起来舒服一点
[解决办法]
引用:
这种题目是开放的。也就是说一个题目有很大的区分度,即便最差的人,也能写出一个大概,而优秀的人可以写出性能良好,考虑边界条件,代码清晰的代码。而通过一个题目,则可以看出一个人的水平。

相反,过于简单的题目,比如实现一个hello world,高手菜鸟写出的程序没有区别。就无法看出面试者水平高低了。类似的,过于复杂的题目,很多人交了白卷,也不能区分他们的差别(完全不会,还是会一点)。

这种题目没有标准答案,如果你仅仅满足一个可以运行的程序,那你就输了。



版主,我的答案能给多少分!假如100分的题!


        static void Main(string[] args)
        {
            List<Tuple<string, int, int>> list = new List<Tuple<string, int, int>>();//无需声明实体
            list.Add(new Tuple<string, int, int>("A01", 198, 97));
            list.Add(new Tuple<string, int, int>("A02", 90, 103));
            list.Add(new Tuple<string, int, int>("A03", 123, 100));
            list.Add(new Tuple<string, int, int>("A04", 77, 87));
            list.Add(new Tuple<string, int, int>("A05", 10, 54));
            list.Add(new Tuple<string, int, int>("A06", 81, 104));
            list.Add(new Tuple<string, int, int>("A07", 110, 87));
            list.Add(new Tuple<string, int, int>("A08", 45, 41));
            list.Add(new Tuple<string, int, int>("A09", 123, 99));
            list.Add(new Tuple<string, int, int>("A07", 140, 88));
            list.Add(new Tuple<string, int, int>("A07", 109, 98));
            double Avg = list.Average(a => a.Item2);//求平均值
            list = list.OrderByDescending(a => a.Item2).ToList();//从大到小排序


            foreach (var item in list)
            {
                string str;
                if (item.Item2 >= Avg)
                {
                    str = "留下来";
                }
                else
                {
                    str = "被淘汰";
                }
                Console.WriteLine(string.Format("编码{0} 销售{1}件 工作热情为{2}分 结果:{3}", item.Item1, item.Item2, item.Item3, str));
            }
            Console.ReadKey();
        }
    }


[解决办法]
引用:
Quote: 引用:

借用楼上的代码,修改一下
class Program
{
    static void Main(string[] args)
    {
        List<Sales> lsales = new List<Sales>()
        {
            new Sales{Num="A01",Performance=198,Score=97},
            new Sales{Num="A02",Performance=90,Score=103},
            new Sales{Num="A03",Performance=76,Score=78},
            new Sales{Num="A04",Performance=123,Score=100},
            new Sales{Num="A05",Performance=77,Score=87},
            new Sales{Num="A06",Performance=10,Score=54},
            new Sales{Num="A07",Performance=81,Score=107},
            new Sales{Num="A08",Performance=110,Score=87},
            new Sales{Num="A09",Performance=45,Score=41},
            new Sales{Num="A10",Performance=123,Score=99},
            new Sales{Num="A11",Performance=140,Score=88}
        };
        var avr = lsales.Average(s => s.Performance);
        foreach (var sl in from s in lsales
                            where s.Performance > avr
                            orderby s.Performance descending
                            select s)
        {
            Console.WriteLine(sl.Num + " " + sl.Performance + " " + sl.Score);
        }
        Console.ReadLine();

    }

}

class Sales
{
    string num;

    public string Num
    {
        get { return num; }
        set { num = value; }
    }
    int performance;

    public int Performance
    {
        get { return performance; }
        set { performance = value; }
    }
    int score;

    public int Score
    {
        get { return score; }


        set { score = value; }
    }
}



            var avr = lsales.Average(a=>a.Performance);
            foreach (Sales item in lsales.Where(s => s.Performance > avr).OrderByDescending(s=>s.Performance))
            {
                MessageBox.Show(item.Num);
            }
我还是觉得我这个看起来舒服一点


 

热点排行