- 博客(89)
- 资源 (1)
- 收藏
- 关注
原创 JS sort方法踩坑
例如,对于[2, 11]这个数组,按照字符串的排序规则,数字2的字符串表示比数字11的字符串表示要大(因为2开头的字符串比11开头的字符串在字典序上大)。因此,经过默认的sort()排序后,会得到[11, 2]这个结果。JavaScript的sort()方法在默认情况下将数组元素视为字符串进行排序,而不是按照数字的大小。因此,对于包含数字的数组,sort()方法会按照字符串的排序规则进行排序。
2024-04-13 23:39:49
255
原创 JS 时间戳踩坑
如果这个字符串具体到月份或者日期,则对应的是当月1日/当日 0点整。将一个年份的字符串转为时间戳对应的是当年1月1日8点整。时间戳0对应的是1970年1月1日8点整。
2024-03-14 18:23:29
399
原创 关于“为什么创建Vue实例时传入的参数中的data属性的值应该是函数而非对象”
为什么创建Vue实例时传入的参数中的data属性的值应该是函数而非对象
2022-11-02 14:15:30
202
原创 中缀式借栈转后缀式
考点:转换过程中同时保存在栈中的操作符的最大个数。swust oj 1042 中缀式转后缀式#include <bits/stdc++.h>using namespace std;map<char, int> isp; ///in stack prioritymap<char, int> icp; ///in coming priorityvoid init(){ isp['('] = 1; isp[')'] = 6;
2021-06-17 14:13:42
246
原创 顺序表再次动态申请空间时,计算机自动完成copy
顺序表的插入算法中,若n个空间已满,可再申请增加m个空间,若申请失败,说明内存中已没有n+m个连续‾\underline{n+m个连续}n+m个连续可分配的空间。若申请成功,原位置的内容由计算机自动完成copy。#include <iostream>using namespace std;int main(){ int * a = (int *)malloc(sizeof(int) * 2); a[0] = 0; a[1] = 1; cout <
2021-06-14 23:11:26
1088
1
原创 C++ sort(first_argument_is_more_back, second_argument_is_more_front)
#include <iostream>#include <algorithm>using namespace std;int arr[] = {4, 2, 3, 1};bool cmp(int back, int front){ for(int i = 0; i < 4; ++i) cout << arr[i] << ' '; cout << '\n'; cout << "f
2020-08-03 17:27:02
133
原创 Java没有指针,一切都是对象,一切都是引用。
#include<bits/stdc++.h>using namespace std;class node{public: int data; double t;};int main(){ node n1; n1.data = 4; n1.t = 3.14; node n2 = n1; cout <&l...
2020-04-22 16:15:17
531
原创 冒泡排序
#include <stdio.h>#include <iostream>using namespace std;void Sort(int * a, int len){ for(int i = len - 1; i >= 1; --i) for(int j = 0; j <= i - 1; ++j) i...
2019-09-29 19:37:50
142
转载 C++与G++
用C++代码敲代码,一般都会用C++提交,但是后由于一些细微的不同使用不同的编译方式还是会产生差别的,甚至是WR和AC的天壤之别。原来只知道C++能用C++提交,但是原来G++…从网上找了点资料:G++是GNU的那个C++编译器,也是Dev-CPP自带的编译器和NOI系列赛官方的编译器。。而C++是VC++,是微软出的编译器。。。一般来说,两个结果不一样,要么是因为G++效率略低被卡掉,要...
2019-05-06 17:52:54
554
转载 关于 ++i 快于 i++
当然,很多时候我们有的代码用C++提交通过了,但是G++却失败了呢?众所周知,不同的编译器,会对代码做出一些不同的优化。举一个最简单的例子。针对单个语句(注意,是单个语句,不是包含在语句中的那种前++和后++):a: a++;b: ++a;一般的讲,我们都知道,这两条语句的最终结果是一样的,就是a自己增加了1。但是,两者的差距还是有的。如果从标准C的角度去理解。a++这个语句等同于a: a ...
2019-03-28 12:13:24
937
原创 牛客练习赛37.A
链接:https://ac.nowcoder.com/acm/contest/342/A来源:牛客网题目描述筱玛是个快乐的男孩子。寒假终于到了,筱玛决定请他的朋友们一起来快乐。对于筱玛来说,最快乐的事情莫过于翻看万年历上的日期了。一个日期是“快乐”的,当且仅当这一年的年份是一个质数,且将月份、日期写成"MM-DD"的形式后是对称的。如:"2003-01-10"是“快乐”的。筱玛有n个...
2019-01-11 21:10:59
382
原创 Catch That Cow POJ3278
DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0...
2019-01-11 19:27:00
217
原创 Dungeon Master POJ2251
DescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit ...
2019-01-11 17:33:31
195
原创 1321棋盘问题
Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , ...
2019-01-11 12:28:48
163
原创 单向链表的建立(封装)
链表在main函数里写是一回事,封装成独立函数会有新问题…#include<bits/stdc++.h>using namespace std;struct Node ///(结点形式){ int data; ///数据域 struct Node * next; ///指针域};type...
2019-01-09 21:29:11
309
原创 A. Boy or Girl
Those days, many boys use beautiful girls’ photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat w...
2019-01-09 11:16:29
3940
原创 A. System Administrator
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers’ performance, Polycarpus executes commands “ping a” and “ping b”. Ea...
2019-01-09 11:05:21
390
原创 A. Bear and Reverse Radewoosh
Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equally skilled but they won’t solve problems in the same order.There will be n problems. The...
2019-01-09 10:50:44
370
原创 A2. Good Matrix Elements
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good:Elements of the ...
2019-01-08 21:46:50
752
原创 A. Team
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long befo...
2019-01-08 21:24:20
648
原创 A. Domino piling
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as m...
2019-01-08 21:17:49
629
1
原创 A. Word Capitalization
Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.Note, that during capitalization all the letters except the first one remains unc...
2019-01-08 20:50:27
320
原创 A. Tom Riddle's Diary
Harry Potter is on a mission to destroy You-Know-Who’s Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is Tom Riddle’s diary. The diary was with Ginny and it forced her to o...
2019-01-07 21:35:58
658
原创 A. Golden Plate
You have a plate and you want to add some gilding to it. The plate is a rectangle that we split into w×hw×h cells. There should be kk gilded rings, the first one should go along the edge of the plate,...
2019-01-07 21:23:14
319
原创 A. Way Too Long Words
Sometimes some words like “localization” or “internationalization” are so long that writing them many times in one text is quite tiresome.Let’s consider a word too long, if its length is strictly mor...
2019-01-07 15:38:50
565
原创 A. Fingerprints
You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits....
2019-01-07 15:29:51
323
原创 A. Petya and Origami
Petya is having a party soon, and he has decided to invite his nn friends.He wants to make invitations in the form of origami. For each invitation, he needs two red sheets, five green sheets, and eig...
2019-01-07 15:14:15
286
原创 A. Dice Rolling
这题完全考英文翻译!!!Mishka got a six-faced dice. It has integer numbers from 22 to 77 written on its faces (all numbers on faces are different, so this is an almost usual dice).Mishka wants to get exactly x...
2019-01-06 21:58:13
953
原创 A. Make a triangle!
Masha has three sticks of length aa, bb and cc centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks....
2019-01-06 21:40:48
954
原创 A. Scarborough Fair
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.Willem asks his friend, Grick for directions, Grick helped them, and gave them a tas...
2019-01-06 21:29:35
716
原创 A. Game
Two players play a game.Initially there are nn integers a1,a2,…,ana1,a2,…,an written on the board. Each turn a player selects one number and erases it from the board. This continues until there is on...
2019-01-06 21:18:52
369
原创 B. Teams Forming
There are nn students in a university. The number of students is even. The ii-th student has programming skill equal to aiai.The coach wants to form n2n2 teams. Each team should consist of exactly tw...
2019-01-06 21:00:42
492
原创 A. Vitaly and Night
One day Vitaly was going home late at night and wondering: how many people aren’t sleeping at that moment? To estimate, Vitaly decided to look which windows are lit in the house he was passing by at t...
2019-01-06 20:54:30
238
原创 A. Repeating Cipher
Polycarp loves ciphers. He has invented his own cipher called repeating.Repeating cipher is used for strings. To encrypt the string s=s1s2…sms=s1s2…sm (1≤m≤101≤m≤10), Polycarp uses the following algo...
2019-01-06 20:46:00
252
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人