工作配对#1【难度:0级】: 答案1: using StriveObjects; using System;public class Strive {public static bool Match(Candidate c, Job j){if (c.MinSalary == null || j.MaxSalary == null){throw new Exception();}return (c.MinSalary * 0.9 <= j.MaxSalary); } }? 答案2: using StriveObjects; using System;public class Strive {public static bool Match(Candidate c, Job j){if (c.MinSalary == null || j.MaxSalary =...
下文图片出自C#与.NET+4高级程序设计+第5版与百度 .NET理解为一个运行库环境和一个全面的基础类库。 .NET三个关键实体(构造块):CLR、 CTS、 CLS 公共语言运行库层为CLR 。功能:定位加载和管理.NET类型。也负责底层的工作如内存管理,处理线程等等。 公共类型系统:CTS 。 描述了运行库所支持所有可能的数据类型和编程结构。 公共语言规范:CLS。定义所有.NET都支持的公用类型和编程结构的子集。 Reflector查看程序集,反编译...
C#基础之数组1. 数组的定义与初始化一维数组: (1) int [] A = new int[4]{ 0,1,2,3}; (2) int[] B = new int[4/变量]; (3) int[] C = { 1, 2, 3, 4 }; (4) int[] D; D = new int[4] { 1, 2, 3, 4 }; 注意: (1) int [] A 第一个[] 不能有行数限制,要在new里设置。 (2) new 表示的是创建数组并初始化。Int型为0,bool型为false,引用类型为null (3) 如...
csharp基础练习题:数字对【难度:1级】: 在这种习题目的是每对整数2个数组矩阵比较,并返回大量的新的数组. 注意:两个数组具有相同的尺寸. 例: ARR1 =新INT [] {13,64,15,17,88}; ARR2 =新INT [] {23,14,53,17,80};Kata.getLargerNumbers(ARR1,ARR2); //返回{23,64,53,17,88} ARR1 = [13,64,15,17,88] ARR2 = [23,14,53,17,80] get_larger_numbers(ARR1,ARR2)== [23,64,53,17,88] ARR1 = [13,64,15,17,88] ARR2 = [23,14,53,17,80] g...
滑稽的算法任务【难度:2级】: 答案1: using System; using System.Linq;public class NumbersFinder {public static int Generator(int size, int position){if (position < 1 || position > Math.Pow(size, size)) return -1;var sum = "";position--;for (var i = 0; i < size; i++){sum = ((position % size) + 1).ToString() + sum;position /= size;}return int.Parse(sum);} }? 答案2: using System; using System.Collectio...
简单的等式2【难度:1级】: 答案1: namespace SolveIt { using System; using System.Linq; using System.Text.RegularExpressions;public class Kata{public static int result(string s){return Regex.Matches(s.Replace(" ",""),"[-]?[0-9]+").OfType<Match>().Select(x=>int.Parse(x.Value)).Sum();}} }? 答案2: namespace SolveIt {public class Kata{public static int result(string sI){string [] sS=sI.Replace(" ","").Re...
停止gninnipS我sdroW!【难度:2级】: 答案1: using System.Collections.Generic; using System.Linq; using System;public class Kata {public static string SpinWords(string sentence){return String.Join(" ", sentence.Split(' ').Select(str => str.Length >= 5 ? new string(str.Reverse().ToArray()) : str));} }? 答案2: using System.Collections.Generic; using System.Linq; using System;public class Kata {public st...
数字对【难度:1级】: 答案1: using System; using System.Linq; public class Kata {public static int [] getLargerNumbers(int[] a, int[] b) {return a.Zip(b, (x, y) => Math.Max(x, y)).ToArray();} }? 答案2: using System; using System.Linq;public class Kata {public static int [] getLargerNumbers(int [] a , int [] b)=> a.Zip(b, (x,y) => Math.Max(x,y)).ToArray(); }? 答案3: using System; using System.Collect...
抛体运动【难度:2级】: 答案1: using System; using System.Globalization; using System.Xml.Schema;public class Projectile {public double StartingHeightFeet { get; private set; }public double StartingVelicityFeetSecond { get; private set; }public double AngleDegrees { get; private set; }public Projectile( double startingHeightFeet, double startingVelocityFeetSecond, double angleDegrees ) {if ( startin...
csharp基础练习题:查找组合【难度:1级】: 你的目标是计数的字母或符号某个词或组合出现了多少次在字符串中.关键是不区分大小写,可以在字符串中出现的许多或几十倍.该函数声明为您提供的并且应该有两个参数与返回计数一个返回变量.叠词不应该算作一次以上!空字符串不能是一个关键.该功能还应该能算整数和字符数.认真想! 例: countCombinations("我的名字叫比利和比利是真棒","比利"); // 2 countCombinations( 'abcdefghijklmonopol...
比萨件【难度:2级】: 答案1: public class Pizza {public static int maxPizza(int cut) {return cut<0?-1:1 + cut*(cut+1)/2;} }? 答案2: public class Pizza {public static int maxPizza(int cut) {return cut<0 ? -1 : (int)(0.5*cut*(cut+1)+1);} } ? 答案3: using System;public class Pizza {//http://mathworld.wolfram.com/CircleDivisionbyLines.htmlpublic static int maxPizza(int n) {return n < 0 ? -1 : ((int)...
这里没有奇特【难度:1级】: 答案1: using System.Linq;public class NoOddities {public static int[] NoOdds(int[] values) =>values.Where(v => v % 2 == 0).ToArray(); }? 答案2: using System.Linq; public class NoOddities {public static int[] NoOdds(int[] values) => values.Where(x => x % 2 == 0).ToArray(); }? 答案3: using System.Linq;public class NoOddities {public static int[] NoOdds(int[] values) {retur...
查找组合【难度:1级】: 答案1: using System.Text.RegularExpressions;public class Kata {public static int CountCombinations(string text, string key){ return Regex.Matches(text, key, RegexOptions.IgnoreCase).Count;} }? 答案2: using System; using System.Text.RegularExpressions;public class Kata {public static int CountCombinations(string text, string key){return Regex.Matches(text.ToLower(), key.ToLow...
平均计算【难度:0级】: 答案1: using System.Linq;class AverageSolution {public static double FindAverage(double[] array){return array.Length == 0 ? 0 : array.Average();} } ? 答案2: using System.Linq; class AverageSolution {public static double FindAverage(double[] array){// Your code herereturn array.Length == 0 ? 0 : array.Average();} } ? 答案3: using System.Linq;class AverageSolution {public stati...
深名单反向【难度:2级】: 答案1: using System.Linq;public class Kata {public static object[] DeepReverse(object[] l){return l.Select(e => e.GetType().IsArray ? DeepReverse((object[])e) : e).Reverse().ToArray();} }? 答案2: using System; using System.Linq; public class Kata {public static object[] DeepReverse(object[] l){l = l.Reverse().ToArray();for (int i = 0; i < l.Count(); i++){Type typek = l[i].G...