- 博客(10)
- 收藏
- 关注
原创 C#学习笔记——火车票
·二维数组实现出售火车票按座位购票,若该座位有票则购买成功,否则提示座位已售出。需求1:先打印一次座位表,每次购买成功或失败都打印座位。需求2:能正确买票。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace tickets{ class Program { stati
2021-03-27 17:17:00
587
原创 C#学习笔记——二分查找
·二分查找在一个排好序的数组中,如果采用循环遍历查找,最多需要查找N次(N = 数组长度)。这个问题有一个很好的优化算法:二分查找。例如:array = {11, 22, 33, 44, 55, 66, 77, 88, 99};查找数字22,数组长度为9,下标从0到8。(0 + 8) / 2 = 4,看array[4]是否等于22;a.if array[4] == 22,查找结束,结果就是下标4;b.else if array[4] > 22,那么继续查找前半部分,即array[0]到
2021-03-27 16:20:35
390
原创 C#学习笔记——杨辉三角形
·不使用二维数组using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 杨辉三角形{ class Program { static void Main(string[] args) { int n = int.Parse(Console.
2021-03-27 16:07:33
2355
原创 C#学习笔记——数组与抽卡概率控制
习题:有一种非常实用的抽卡概率控制算法,给定两个数组weight = {5, 10, 100, 100, 200 }card = {“SSR”, “SR”, “R”, “A”, “B” }第一个weight数组代表每种卡占的权重第二个card数组代表抽到的是什么卡例如:R卡抽到的概率是:100 / (5 + 10 + 100 + 100 + 200) = 100 / 415输出:按照规定的概率,随机抽出一张卡。using System;namespace 数组与抽卡概率控制{
2021-03-27 15:30:17
1453
1
原创 C#学习笔记——桶排序
·桶排序习题:统计字符出现次数一个任意字符串比如“abc cca bcd”,统计输出它的字符出现次数:a 2b 2c 4d 1using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace BucketSort{ class Program { static voi
2021-03-27 15:20:35
166
原创 C#学习笔记——冒泡排序
·冒泡排序using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApp1{ class Program { static Random random = new Random(); //随机生成0~9组成的数组 static in
2021-03-27 15:09:03
161
原创 C#学习笔记——函数练习,默认参数,函数重载
·生成随机字符串写一个生成随机数的函数RandInt,再实现一个生成字符串的函数,可以指定随机字符串的长度,内容为随机字母和数字。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 随机字符串{ class Program { static Random random =
2021-03-27 14:33:17
216
原创 C#学习笔记——sin函数
·纵向打印sin函数思路:利用双重循环定位一个矩形区域,在区域中找出sin函数对应的点并标记为“ * ”,不在函数图像上的点就标记为“ ”,最后进行适当放缩即可。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 纵向打印sin函数{ class Program {
2021-03-27 13:59:29
4240
原创 C#学习笔记——打印三角形
·打印各种三角形·直角三角形using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 直角三角形{ class Program { static void Main(string[] args) { Console.WriteLine("
2021-03-27 13:38:02
1995
原创 C#学习笔记——打印9x9乘法表
·打印9x9乘法表using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _9x9乘法表{ class Program { static void Main(string[] args) { int product;
2021-03-27 13:24:13
149
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人