自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 codeup 1918 简单计算器

题目:1.读入一个只包含 +,-,*,/的非负整数表达式,计算该表达式的值。每个测试用 例占一行,每行不超过200个字符,整数和运算符之间用一个空格分隔。当一 行只有0时输入结束。2.答案精确到小数点后两位。我的思路:呃,刚刚写了一下,完全是错漏百出啊!难点:1.混淆中序转后序和计算后序表达式的过程2.如何比较优先级3.如何处理输入中的空格4.表达式中的数字是两位以上的#include<iostream>#include<cstdio>#inclu

2021-03-01 19:57:51 92

原创 Uva489 Hangman

"难以想象自己在写这道题时犯了多少错误,都是每一次没有得出正确答案之后硬生生改过来的!!我感觉你的思维真的很不严密!而你每次写完之后就压根没有想过自己测试的问题???还没有提交,记得反思此题!”/*输入一个字符串s,1.猜测一个字符串,每次说出一个字母即可,如果你说的字母不包含在s里且次数超过7次,那么就输了。2.如果你在7次错误以内把s内所含的字符都猜出来了(s中重复的字符只需要猜中一次即可)那么你就赢了。3.如果你猜的字符串既不赢,又没有犯够7次错误,那么给出另外一种结果。 如何

2020-11-01 11:51:58 201 2

原创 Uva11809 Floating-Point Numbers

“觉得这道题挺难的刚刚开始觉得第一步是要想办法把十进制换位二进制,但是毫无头绪…链接:这篇文章要去看看此题需要好好反思下面是来自code paradise的ac代码:#include <stdio.h>#include <string.h>#include <math.h>#define MIN_ERROR 1e-5double A[10][31];long long B[10][31];void buildTable(){ int

2020-10-26 09:44:11 120

原创 Uva 1588 Kickdown

“我真的是阅读理解0分。这道题目看了一个多小时还是不明白什么意思。感谢Code Paradise的那位软件工程师…要不然我真的不明白。”大体题意:有两种平面齿轮:在上面的叫做driven gear。在底部的叫做master gear。(后来发现我连齿轮的情况也理解错了,题目意思是牙齿在底部的是master gear。牙齿在顶部的是driven gear…额真的这样???)长度为n的一段含有n个单元。每个单元(每个单元的宽度是一样的!!!)要么高为h要么高为2h。高度为h的凹进去,2h的凸出来。现在有一

2020-10-21 10:46:59 112

原创 Uva1587-Box

/*使用结构体排序好六个面判断边相等即可 记得先处理好每个面,保证w>h */#include<stdio.h>#include<algorithm>using namespace std;struct Area{ int w; int h;}area[7];bool cmp(Area a,Area b){ if(a.w != b.w) return a.w > b.w; else return a.h > b.h;}

2020-10-19 08:51:20 88

原创 UVa 10340 All in All

“也是提交尚未回应…”/*输入两个字符串,s和t把s中的各个符号依次在t中寻找即可。但要求各字母出现的顺序要一致。*/#include<stdio.h>#include<string.h>int main(){ char s[100]; char t[100]; while(scanf("%s%s",s,t) == 2){ int sign; int slen = strlen(s); int tlen= strlen(t); i

2020-10-14 18:28:05 75

原创 UVa202 Repeating Decimals

“提交的代码到现在还没有回复,下面的是我通过了三个测试的代码”//循环小数/*当余数序列出现循环时代表小数循环故用一个数组记录余数序列,(不对,因为要统计cycle长度,所以选择记录每个余数的位置是第几个余数order。如果位置已经有人了) 用另一个数组记录小数序列*/#include<stdio.h>int pos[3000]={0};//余数最大不会超过三千int frament[3000];int main(){ int a,b; while(scanf(

2020-10-14 17:37:38 76

原创 Uva1368 - DNA Consensus String

“好像Uva的平台已经不能直接使用了?要在google直接搜索相应题号才可以看题目和提交了”这道题难度不大,思路也比较容易想到。但是我一开始把数组的行下标和列下标颠倒了…花了不少时间。//额哪里有问题!!! //统计每一列中出现最多的字母即可#include<stdio.h>char dna[60][10010];char ch[4] = {'A','C','G','T'};int main(){ int T; int m,n; scanf("%d",&a

2020-10-11 09:05:13 79

原创 Uva232 Crossword Answers

/*1.因为输入的两个整数决定了这一次循环要接收的字符数,所以可以通过判断第一个数字是否为0来结束输入。2. 判断是否标记数字。whitesquare的左边或上边若没有whitesquare,则可以标上3.打印时如何判断一个标号是已经打印还是应该要从他打印起? 设置记号法不可取,因为across输出会影响down输入。 Across: 对于某一行,从第一个开始输出,直到遇到边界或者遇到黑格 Down: 如果这个whitesquare的上面不是whitesquare即可要以它为起始

2020-10-04 18:55:20 791

原创 UVa227 Puzzle

题型:模拟注意:1.使用getchar接收,注意接收回车符。2.每一个移动操作之后,记得改变空格位置。3.任重而道远。这道题的难度只是easy,但是对于我来说却不那么容易…#include<stdio.h>int main(){ int puzzlecase = 1; int firstcase = 1; char temp, cmd; char puzzle[5][5]; while( (temp=getchar()) != EOF && tem

2020-09-23 09:09:32 73

原创 UVa455 periodicStrings

找一个字符串的最小周期。我感觉我自己写的这段代码没有任何问题,但是它居然不承认 ‘a’ == ‘a’!#include<stdio.h>#include<string.h>const int maxn = 100;int main(){ int T; char s[maxn]; scanf("%d",&T); while(T--){ scanf("%s",s); int len = strlen(s); int mask=0;

2020-09-15 08:06:21 64

原创 UVa1586计算分子质量

#include<stdio.h>#include<string.h>#include<ctype.h>char element[] = {'C','H','O','N'};double mass[] = {12.01, 1.008, 16.00, 14.01};const int maxn = 100;int main(){ int T; scanf("%d",&T); //char str[maxn]; while(T--){ c

2020-09-14 10:53:12 85

原创 用1到9组成3个比例为1:2:3的三位数

要求每个数字恰好使用一次。思路:用一个数组记录每个数字的使用情况。#include<stdio.h>int visit[10] ={0};void breakNum(int n){ int a = n/100; int b = n/10 % 10; int c = n%10; visit[a] = 1; visit[b] = 1; visit[c] = 1;}int main(){ for(int n1=123; n1<333;n1++){ int n2=

2020-08-31 08:57:56 745 1

原创 矩阵中的路径

“我做了算法笔记的几道例题,以为DFS类型的题目都吃透了,结果这道变一下又不会了…”题目:请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子。如果一条路径经过了矩阵中的某一个格子,则该路径不能再进入该格子。矩阵中包含一条字符串"bcced"的路径,但是矩阵中不包含"abcb"路径,因为字符串的第一个字符b占据了矩阵中的第一行第二个格子之后,路径不能再次进入该格子。== 注意这里的二维矩阵

2020-08-24 08:43:57 191

原创 脑筋急转弯

1.一个房间有3盏灯,房间外有3个开关分别控制3盏灯,在只能进房间一次的情况下,如何判断哪个开关控制哪个灯?先开一盏灯,过5分种关掉,在开另外一盏灯。进房间。摸一下另外两盏不亮灯的灯泡,哪个灯泡烫就是你开的第一盏灯,灯泡亮的是你开的第二盏灯,...

2020-08-16 14:33:21 212

原创 剑指OFFER之数组篇

“根据B站up主土妹的方法,像以前高中初中复习一样来锻炼自己做算法题的能力!!!把剑指OFFER的题目作为例题,系统学习一个知识点之后,在去做Leetcode的题目。”“加油!”@[TOC](目录)JZ66 机器人的运动范围地上有一个m行和n列的方格。一个机器人从坐标0,0的格子开始移动,每一次只能向左,右,上,下四个方向移动一格,但是不能进入行坐标和列坐标的数位之和大于k的格子。 例如,当k为18时,机器人能够进入方格(35,37),因为3+5+3+7 = 18。但是,它不能进入方格(35,38)

2020-08-10 15:12:08 84

原创 Interfaces和Abstract classes的比较

interface:All methods must be public.All variables must be public static final.Cannot be instantiatedAll methods are by default abstract unless specified to be defaultCan implement more than one interface per classabstract class:Methods can be pu

2020-08-02 18:00:10 109

原创 Type Checking and Casting

You may be wondering, how does Java know which print() to call? Good question. Java is able to do this due to something called dynamic method selection.We know that variables in java have a type.List61B<String> lst = new SLList<String>();In

2020-07-26 17:46:33 221

原创 Lab 3: Unit Testing with JUnit, Debugging

In this lab, you will learn about Unit Testing, JUnit, the 61B style checker, and we’ll also get a bit more debugging experience.If you just want to use the renderer that you already selected, you can bypass having to pick between the two renderers in any

2020-07-26 01:01:32 144

原创 CS61B Discussion05

目录一道不明白意思的题目经常要犹豫很久担心写错的删重一道不明白意思的题目经常要犹豫很久担心写错的删重

2020-07-24 16:55:47 84

原创 CS61B project0实验记录

1.copy一个行星构造函数不会写2.常数用 static final 修饰比较好3.java支持科学记数法,例如 1.03e-7;4.foreach循环的使用 for( type name : arrayname);

2020-07-23 18:40:57 1045 1

原创 overriding 和 overloading

“老是忘记这个…”if a subclass has a method with the exact same signature as in the “superclass”, we say the subclass overrides the method.Methods with the same name but different signatures are overloaded.

2020-07-12 11:42:27 120

原创 LinkedList和Arrays的练习

LinkedList练习)插入节点在原有链表的基础上逆转元素顺序插入节点在以下代码的基础上完成插入节点的功能。例如:5–6--2,insert (10,1) result in 5–10–6--2.这里的position是从0开始的public class SLList{ private class IntNode{ public int item; public IntNode next; public IntNode(int item, IntNode next){ thi

2020-07-11 01:48:33 131

原创 补码非

“我想有一个浓度很大的成长…”深入理解计算机系统练习题题 2.30写一个函数,当参数x和y相加不会产生溢出,这个函数就返回1。int tadd_ok(int x,int y){ int sum = x+y; int neg_over = x<0 && y<0 && sum >= 0; int pos_over = x>=0 && y >= 0 && sum < 0; return !neg_ov

2020-07-06 22:29:20 396

原创 Leetcode数组专题(Medium): 18.4Sum

Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:The solution set must not contain duplicate .

2020-07-06 15:37:50 97

原创 自己遇到的一个小BUG

public static IntList catenate(IntList A, IntList B) { //TODO: fill in method if(A == null && B == null) return null; IntList L; IntList Ap = A.rest; while(Ap != null){ L.rest = new .

2020-06-29 15:48:21 90

原创 把两个链表链接起来

public static IntList dcatenate(IntList A, IntList B) { //TODO: fill in method if(A == null && B == null) return null; IntList L = A; while(L != null){ L = L.rest; }

2020-06-29 15:15:33 1155

原创 Leetcode数组专题(Medium): 15.3Sum

“独立思考”Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not contain duplicate triplets.Example:Given array nums

2020-06-27 16:16:21 94

原创 Leetcode数组专题(medium):11.Container With Most Water

“I’m so small…”Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms

2020-06-25 10:50:32 92

原创 LeetCode数组专题: 268.Missing Number

“为什么你没有经常来!”class Solution { public int missingNumber(int[] nums) { int n = nums.length; int totalSum = n*(n+1)/2; int res = 0; for(int num : nums){ res = totalSum - num; } return res; }

2020-06-24 22:22:31 98

原创 LeetCode数组专题: 217. Contains Duplicate && 219. Contains Duplicate II

“来啦来啦!!!”217.Contains DuplicateGiven an array of integers, find if the array contains any duplicates.Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.Example 1:I

2020-06-17 23:24:48 132

原创 LeetCode数组专题: 189. Rotate Array

"加油!相信自己”189. Rotate ArrayGiven an array, rotate the array to the right by k steps, where k is non-negative.Follow up:Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem.Could you do it in-place with

2020-06-17 21:52:00 104

原创 LeetCode算法专题一:数组(3)

“昨晚一晚没有睡,还不是因为做什么有意义的事情!希望最近调整过来!”121Best Time to buy and sell stockSay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share

2020-06-13 00:14:49 202

原创 用cmd和Git Bash运行Java文件遇到错误

“I can fix any problems…”今晚按照一份配置指示安装了Git Bash,并通过设置后系统环境变量等配置好Java在GitBash上命令行的使用,结果吃完饭回来又不行了…具体表现为输入javac会显示没有这个命令之类的提示语。应该是我的jdk自动更新所致的。我看了一下环境变量里的内容是没有改变的,除了重新安装jdk之外想不到其他更好的方法。但是意外发现在另外一个盘安装有jdk,便把环境变量里的地址改为这个。结果运行成功了。这个问题可能是jdk自动更新成功的。“问题来了,怎么让

2020-06-10 09:24:21 388

原创 计算机网络之分组交换和电路交换

“楼下的手抓饼好香啊”1.分组交换(1)通过通信链路和分组交换机(路由器或链路层交换机)(2)存储转发传输和非存储转发传输。前者需要被整个分组存储下来再转发。(3)排队时延和分组丢失。(4)转发表和路由选择协议。2.电路交换主要特点:预留端系统间通信所需要的资源(缓存,链路传输速率)电路交换链路中的电路是通过频分复用(FDM)和时分复用(TDM)实现的。3.分组交换和电路交换的对比(1).分组交换不适合实时服务(电话和视频会议)。因为排队时延的变动和不可预测导致端到端时延是可变和不可预测

2020-06-08 17:35:12 715

原创 一天时针和分针重合多少次

“加油加油加油!!!”这个问题有点难,我一开始觉得有25次,理由是,0:00的时候重合(第一次),然后开跑,每小时追上一次,最后回到0:00.所以一共1+24=25次。哎,真的是不知道怎么考虑问题。是不是忽略了几个条件:1.谁说一定在0:00开始?2.谁说开始的时候时针和分针一定重合?3.真的是一个小时追上一次?有没有这么一种情况:在一个小时结束时恰好追上的时候,那么这一次是不是既被算在了这一个小时又被算在了另外一个小时上?几个网上的答案:1.22次重合时间:0:00;bai1:06:;

2020-06-06 17:29:26 1974 1

原创 LeetCode算法专题一:数组(2)

“Life is good!”35.Search Insert PositionGiven a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.我的基础太薄弱了!我知道要用

2020-06-03 07:01:30 196

原创 LeetCode算法专题一:数组

“加油啊,坚持下去吧!”1.Two Sum我遇到的问题:觉得解决思路很简单。但是因为想使用Java来写,居然有几点不知道如何下手。我怎么接收测试的数组??函数要返回一个数组,而这个数组的长度是2,我要怎么处理??后来惊讶的发现,只需要实现方法即可…class Solution { public int[] twoSum(int[] nums, int target) { int l = nums.length; for(int i=0;i<l;i++){

2020-05-28 07:05:37 305

原创 刷LeetCode动员大会!

“今天中大的老师打电话给我说补录的机会很小了,我真的要三战了!…”我打算从今天开始刷LeetCode,使用国际版的,练好一点英语!一共刷两遍,第一遍分类刷,第二遍按题号刷。重点在于第一遍!!!做每道题的步骤如下:1.看懂题目2.分析题意3.写代码4.至少看三个discussion,尽量找到最优解!5.如果是新的知识点要先学习5.写博客记录!“如果坚持就可以胜利的话,为什么不呢?”...

2020-05-28 05:14:56 72

原创 我的一点小火花

“感觉实现了的话,这会完全开辟一个新的学科,而且彻底改变世界!”我现在想写一段Python代码来帮我批量处理一个问题:为一张图片和一组图片对比图片相似度。因为没有怎么写过,这真的有点难为我。我在想,如果有一个类似于已经驯化好的了人工智能(恕我还没有想好它的具体名字!)他能记住我的操作:例如打开两张图片所在的具体路径,然后图片相似度的比较。 此时,人工智能已经记住了我的一次操作,并生成了代码!然...

2020-04-27 01:37:14 96

空空如也

空空如也

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

TA关注的人

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