随笔分类 - 编程面试
WPF-在Grid中编程添加控件
摘要:WPF, 在Grid中编程添加控件,布局控件的位置。
阅读全文
字符串反转C#的实现
摘要:字符数组反转, how are you, 反转后为you are how.
阅读全文
33条C#和.NET经典面试题目及答案
摘要:1. .NET中类和结构的区别? 答:结构和类具有大体的语法,但是结构受到的限制比类要多。 a. 结构不能有默认的构造函数,因为结构的副本是用编译器创建和销毁的,所以不需要默认的构造函数和析构函数。 b. 结构是值类型, 所以对结构变量所做的改变不会影响其原值,而类是引用类型,改变其变量的值会改变其
阅读全文
简易二分查找算法
摘要:class Program { static void Main(string[] args) { int[] arr = new int[] { 5,10,50,200,1000,10001}; int index = BinarySearch(arr, 5, 5, 10001); } static int BinarySearch(int[] array, int left, int right, int value) { int mid; ...
阅读全文
最大递增子串长度
摘要:如:1,-1,2,-2,3,-3,4,5,6 - 最大递增子串长度为5.最直观的O(N*N)算法: static int LongestSubString(int[] array) { int[] Lst = new int[array.Length]; for (int i = 0; i < array.Length; i++) { for (int j = 0; j < i; j++) { if (a...
阅读全文
递归的现实应用
摘要:问设有50个台阶的楼梯, 若一个人上楼梯跨出一步有三种迈法:一次上1个台阶, 一次上2个台阶, 一次上3个台阶。 问总共有多少种不同的上楼方式?考虑他迈最后一步的情况, 即最后一步上了1个台阶, 也可能上了2个台阶, 也可能上了3个台阶。Last step=1 -> 前边有(50-1) 个台阶-> 49个台阶有多少种上楼方式Last step=2 -> 前边有(50-2) 个台阶 -> 48个台阶有多少种上楼方式Last step=3 -> 前边有(50-3) 个台阶 -> 47个台阶有多少种上楼方式所以, 50个台阶情况=49个台阶的情况+48个台阶的情况
阅读全文
Josephus 问题
摘要:Josephus Problem C#实现:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceJosephus{classProgram{staticvoidMain(string[]args){JosephusOutput(-11,10);}staticvoidJosephusOutput(intM,intN){//Inputvalidationcheckif(M<0||N<0)return;//InitializethesequenceJosephusDa
阅读全文
均匀设计U Star 665
摘要:均匀设计U Star 6行5列, 标准数位6Current Column Values Are: 2 3 4 5 6 1 2 3 4 5 6 2 4 6 1 3 5 3 6 2 5 1 4 4 1 5 2 6 3 5 3 1 6 4 2 6 5 4 3 2 1 我最喜欢的一组数:Current Column Values Are: 1 3 4 5 6 1 1 3 4 5 6 2 2 6 1 3 5 3 3 2 5 1 4 4 4 5 2 6 3 5 5 1 6 4 2 6 6 4 3 2 1 Current Column Values Are: 1 2 4 5 6 1 1 2 4 5 6 2
阅读全文
栈: 栈借助数组逆序或数组借助栈逆序_tack.ToArry()
摘要:下面的代码示例演示 Stack 泛型类的几种方法,其中包括 Peek 方法。 此代码示例创建具有默认容量的字符串堆栈,并使用 Push 方法将五个字符串压入堆栈。枚举堆栈的元素,这不会更改该堆栈的状态。使用 Pop 方法将第一个字符串弹出堆栈。使用 Peek 方法查看此堆栈中的下一个项,然后使用 Pop 方法将其弹出。使用 ToArray 方法创建数组并将堆栈元素复制到其中,然后将数组传递给具有 ...
阅读全文
雷:面试时被问到fibonacci
摘要:1 1 2 3 5 8...递归:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--staticintFibonacciRecursive(intn){if(n==1||n==2)return1;elseif(n>=2){returnFibon...
阅读全文
打印输入字符串的字母所有顺序的排列
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--staticvoidPrintSequenceString(stringinputStr){if(string.IsNullOrEmpty(inputStr))thrownewArgumentNull...
阅读全文
查找第一次出现的子串位置
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--staticintReturnIndex(stringinputStr,stringsubStr){if(string.IsNullOrEmpty(inputStr))thrownewArgument...
阅读全文
统计字符出现的次数
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--staticvoidReturnShowCOunt(stringinputStr){if(string.IsNullOrEmpty(inputStr))thrownewArgumentNullExce...
阅读全文
考虑无符号整数的二进制中1的个数
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--staticintCountOneInInteger(intvalue){intiter=1;intcount=0;for(inti=0;i<32;i++){if((value&iter...
阅读全文
整数转字符串
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--staticstringTransToString(intvalue){intstep=1000000000;char[]results=newchar[10];intindex=0;if(value...
阅读全文
浙公网安备 33010602011771号