匿名用户
u3d程序员
·成都
感觉靠谱
笔试题只是面向无经验实习生,笔试题基本是算法
5道题:
1、排序算法;
2、判断是否是2的阶次方;
3、日期算法;
4、数组打乱顺序;
5、面向对象思想实现篮子中鸡蛋苹果的交换。
1、冒泡排序,快排,写成静态扩展泛型方法,继承ICompareble。
2、2的阶次方的数的特点是在2进制表现为 1000000.....0, return (number > 0) && ((number & (number - 1)) == 0);
3、日期的有难度,网上有通用算法,但是我觉得现场很难考虑到那么周全,涉及到判断闰年;
4、很多解法,我用的是随机位置交换
public static void DisorderArray(this T[] array) { Random rand = new Random(); for (int i = 0; i < array.Length; i++) { int randomNum = rand.Next(0, array.Length); if (randomNum != i)//换位置 { var index = array[i]; array[i] = array[randomNum]; array[randomNum] = index; } } }
5、namespace 篮子交换{ class Program { static void Main(string[] args) { People wang = new People { name = "王先生" }; Basket basketA = new Basket { name = "A", loads=new Apple ("苹果",1) }; Basket basketB = new Basket { name = "B", }; Load loadB = new Egg("土鸡蛋", 1); wang.LoadBasket(basketB, loadB); wang.ChangeBasketLoads(basketA,basketB); } } public class People { public string name; public void ChangeBasketLoads(Basket basketA,Basket basketB) { var tempLoads = basketA.loads; basketA.loads = basketB.loads; basketB.loads = tempLoads; } public void LoadBasket(Basket basket,Load load) { basket.loads = load; } } public class Basket { public string name; public Load loads; } public abstract class Load { public string loadName; public int loadAmount; } public class Egg:Load { public Egg(string name,int Amount) { loadName = name; loadAmount = Amount; } } public class Apple : Load { public Apple(string name, int Amount) { loadName = name; loadAmount = Amount; } }}
首先:所有要求1小时内完成,而且,手写, 所以我觉得能提供伪码应该就成,其次:unity和erlang用的同一套题,unity要求应该低一点。
...查看全文
贡献于两年前