自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 收藏
  • 关注

原创 2021-08-31链表练习

链表部分 NC78 反转链表 定义前驱结点prev、next 、 在这里插入代码片 public class Solution { public ListNode ReverseList(ListNode head){ if(head==null){ return null; } ListNode prev = null; ListNode next = head; while(head!=null

2021-08-31 20:38:02 77

原创 牛客N105 二分查找

牛客N105 二分查找 二分查找知道怎么写,就是每次写都会出错!!! 记录一下 并测试代码 在这里插入代码片 public class test1 { public static int search (int[] nums, int target) { int left =0; int right = nums.length-1; while (left<=right){ int

2021-08-10 10:31:22 103

原创 设计循环队列(java实现)

设计循环队列(JAVA 实现) 设计自己的循环队列 add (入队,添元素) remove (出队,删除队首元素并返回) element (查看,查看队首元素) show (显示数据(遍历)) private int maxSize;//表示数组的最大容量 private int front;// 队列的第一个元素 front=0; private int rear;//队列尾 private int[] arr; public circlequeue(int

2021-04-10 21:30:40 267

原创 对称二叉树 (Java实现)

对称二叉树的实现 力扣 101添加链接描述 思考 把一颗树拆分为 根、左子树p、右子树q; 根为空 对称返回true 判断值是否相等&&左树左子叶 == 右数右子叶 && 左树右子叶 == 右树左子叶, 返回true; 左树 空&& 右树 空,返回true; 左树空 || 右树空 ,返回false; 例如: 代码部分 public boolean isSymmetric(TreeNode root) { if (root ==

2021-03-31 20:43:34 153

原创 Java实现 MyLinkedList

Java实现 MyLinkedList **实现: add(e); add (int index,String e); remove (int index); contains (String e); indexOf (String e) lastIndexOf (String e); isEmpty (); get (int index) set (int index,String e) clear () ** public class MyLinkedlist { public Node

2021-03-26 22:15:52 205

原创 2021-3-23 栈 和 队列(JAVA 实现)

栈 和 队列 ================================================= 栈: 基础 栈是一种特殊的线性表,栈的插入和删除是在表的尾端进行。先入栈的是元素放在栈底,成为栈底元素;先出栈的在栈顶位置,即栈顶元素。栈是后进先出(LOFI),或者先进后出(FILO)。 基本操作: (1)判断空栈 isEmpty (); (2)入栈 push();//将数据 X 压入栈顶 (3)出栈 pop();//删除并返回数据; (4)查看栈顶元素 peek();//查看栈顶元

2021-03-23 16:01:05 128 1

原创 2021-3-2 JAVA 实现数组交换

给的两个数组 实现数组内容交换 public static void swapnum(int[] a, int [] b){ int[] ret = new int[4]; int len = a.length; for(int i=0;i<len;i++){ ret[i] = a[i]; a[i] = b[i]; b[i] = ret[i]; } }

2021-03-02 10:48:47 180

原创 金字塔 2020-12-29

牛客网 1 金子塔: 思路 第i行 i=1:四个空格一个字符\n i=2:三个空格二个字符\n i=3: 二个空格三个字符\n i=4:一个空格四个字符\n i=5:无空格 五个字符\n import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sca = new Scanner(System.in); String ch

2020-12-29 10:00:15 124

原创 模拟实现 strcmp 函数2020-12-21

模拟实现 strcmp 思路: //变量相减 (其中类型需要强制转换) //差给ret // 再对取非 //再和*dst进行与运算 !(ret = ((unsigned char)src - (unsigned char)dst) ) && dst) //指针变量src所指向的字符值(即src)减去 //指针变量dst所指向的字符值(即dst)差值赋给ret,再取非运算,最后与dst进行与运算; unsigned char* 是强制类型转换 int my_strcmp(const cha

2020-12-21 21:11:35 64

原创 模拟实现strcat 2020-12-21

模拟实现strcat //概念:连接字符串的函数 //思路: 1、定义两个个char 字符串数组 2、判断是否为空 3、需要找到指向的字符串的结束位置,指向的字符串连接到其后面,最后再添加’\0’就结束了 char* my_strcat(char* dest, const char* src) { char* ret = dest; assert(dest != NULL); assert(src != NULL); while (*ret) { ret++;//停下来时要用ret的 不可以再

2020-12-21 20:13:45 77 1

原创 模拟实现strcpy函数 2020-12-21

实现strcpy函数 模拟实现strcpy函数 //模拟实现strcpy char* my_strcpy(char* dest, const char* src) { char* tmp = dest; assert(dest != NULL); assert(src != NULL); while ((*dest++ = *src++) != 0) { ; } return tmp; } int main() { char src[] = "abcdefgh"; char dest

2020-12-21 20:00:14 59

原创 模拟实现strlen 函数 2020-12-21

模拟实现srlen 三种方法模拟实现 strlen 函数 (1)计数器方式 看字符串的下一位是否为 \0 ,(其中 \0 的ASCII码为0),不是 \0 则 count++. //函数实现strlen int my_strlen(const char* str)//计数器方式实现 { assert(str); int count = 0; while (*str != 0) { count++; str++; } return count; } int main() { char

2020-12-21 19:57:38 89

原创 冒泡排序 2020-12-20

冒泡排序 一组数据实现冒泡排序。其中调用函数时候,其中需要传输两个参量分别是数组arr,以及数组元素个数sz。其中函数调用的过程中对元素个数不改变,加const,传输数组类型为 int* . #include<stdio.h> void bubble(int* str, const int sz)//函数调用 sz不改变可加const { int i = 0; int j = 0; for (i = 0; i < sz; i++)//趟数 { for (j = 0; j &

2020-12-20 19:46:33 67

原创 统计二进制中1的个数 2020-12-7

统计二进制中1的个数 二进制中统计1的个数,两种方法实现,方法一:二进制转换首先要想到%2 /2的方法来实现二进制的表示;方法二:通过位操作符&(按位与 (有0则0,同1则1))。 方法一: #include <stdio.h> int main() { int n = 11; int i = 0; while (n)//循环语句判断n 转二进制 { if (n % 2 == 1) { i++; } n = n / 2; } printf("%d ",

2020-12-07 16:26:54 138

原创 2020-11-26 三个数字比较大小从小到大排列

编程菜鸟进阶-1 if语句 if语句是用来判断所给的条件是否满足,0为假,非0则为真。 if(x>2) { printf(“hello\n”); } else { printf(“hi\n”); } 他的表达是x>2的值将会是0或者1,其中如果是1,将打印hello;如果是0,将打印hi。 练习 三个数字比较大小从小到大进行排列 3个数字进行比较,首先需要键盘输入三个数字,两两数字分别比较大小。此时需要if语句进行判断。 代码 #include<stdio.h> int a,b,c;

2020-11-26 18:10:52 774 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除