自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 资源 (4)
  • 收藏
  • 关注

原创 1002 写出这个数

读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字。输入格式:每个测试输入包含 1 个测试用例,即给出自然数 n 的值。这里保证 n 小于 10​100​​。输出格式:在一行内输出 n 的各位数字之和的每一位,拼音数字间有 1 空格,但一行中最后一个拼音数字后没有空格。输入样例:1234567890987654321123456789输出样例:...

2019-05-01 22:06:28 129 1

原创 1001 害死人不偿命的(3n+1)猜想 (15 point(s))

卡拉兹(Callatz)猜想:对任何一个正整数n,如果它是偶数,那么把它砍掉一半;如果它是奇数,那么把(3n+1)砍掉一半。这样一直反复砍下去,最后一定在某一步得到n=1。卡拉兹在 1950 年的世界数学家大会上公布了这个猜想,传说当时耶鲁大学师生齐动员,拼命想证明这个貌似很傻很天真的命题,结果闹得学生们无心学业,一心只证(3n+1),以至于有人说这是一个阴谋,卡拉兹是在蓄意延缓美国...

2019-04-05 10:52:04 188

原创 CCF201609-2 火车购票(100分)

 问题描述  请实现一个铁路购票系统的简单座位分配算法,来处理一节车厢的座位分配。  假设一节车厢有20排、每一排5个座位。为方便起见,我们用1到100来给所有的座位编号,第一排是1到5号,第二排是6到10号,依次类推,第20排是96到100号。  购票时,一个人可能购一张或多张票,最多不超过5张。如果这几张票可以安排在同一排编号相邻的座位,则应该安排在编号最小的相邻座位。否则应该安排在...

2019-02-03 19:43:11 175

原创 205. Isomorphic Strings

Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another ...

2018-02-10 16:03:15 159

原创 290. Word Pattern

Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.Exampl...

2018-02-10 15:38:07 163

原创 202. Happy Number

Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares o...

2018-02-09 11:14:08 118

原创 242. Valid Anagram

Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return false.Note: You may assume

2018-02-07 15:07:36 110

原创 C++ 比较数组相等

方法一:int main(int argc, char *argv[]){ std::arrayint, 5> arr1 {1, 2, 3, 4, 5}; std::arrayint, 5> arr2 {1, 2, 3, 4, 5}; if (arr1 == arr2) { std::cout "equal" std::endl; }

2018-02-07 15:02:27 6450

原创 比较char*字符串或者string

比较char*字符串 int strcmp(const char* s1,const char* s2) 两个字符串自左向右逐个字符相比(ASCII值),直到出现不同的字符或遇’\0’为止。 (1). s1 (2). s1==s2,返回值= 0; (3). s1 > s2,返回正数。 cplusplus strcmp比较string对象 int com

2018-02-03 21:06:41 945

原创 3. Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "b", with the le

2018-01-03 10:49:01 149

原创 209. Minimum Size Subarray Sum

Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead.For example, given the array

2018-01-03 10:15:36 164

原创 215. Kth Largest Element in an Array

Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For example, Given [3,2,1,5,6,4] and k = 2, return 5.N

2018-01-02 20:59:25 130

原创 283. Move Zeroes

Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your funct

2018-01-02 16:46:59 129

原创 88. Merge Sorted Array

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional

2017-12-31 21:35:24 147

原创 75. Sort Colors

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0, 1,

2017-12-31 17:44:26 126

原创 80. Remove Duplicates from Sorted Array II

Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice?For example, Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first five elemen

2017-12-31 16:45:21 136

原创 167. Two Sum II - Input array is sorted

Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers suc

2017-12-31 11:54:09 132

原创 26. Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifying the i

2017-12-31 11:39:59 145

原创 27. Remove Element

Given an array and a value, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-place w

2017-12-31 10:51:40 133

原创 String类

字符串内存结构图: 注意:字符串在底层的存储实际就是使用字符数组进行存储。 String str1 = "JavaEE";首先在栈空间声明一个str1变量,然后看字符串常量池是否存在”JavaEE”,如果不存在,则在字符串常量池中新建”JavaEE”(字符数组)。这个值存在一个首地址,将这个首地址赋给str1。String str2 = "JavaEE";字符串常量区已经存在”JavaEE“

2017-02-16 21:15:57 290

原创 java值传递

1、按值调用(call by value)表示方法接收的是调用者提供的值。       按引用调用(call by reference)表示方法接收的是调用者提供的变量地址。 2、一个方法可以修改传递引用所对应的变量值,而不能修改传递值调用所对应的变量值。 3、java程序设计语言总是采用按值调用。也就是说,方法得到的是所有参数值得一个拷贝,特别是,方法不能修改传递给他的任何参数变量的内

2017-02-03 12:44:49 284

原创 二分查找(一) 常见错误

每次遇到二分查找心中都是莫名的恐惧,因为我从来没有写对过。。。 错误一#include <stdio.h>#define SIZE(a) sizeof(a) / sizeof(a[0])int search(int array[], int n, int v){ int left, right, mid; left = 0, right = n; while (left <

2016-12-12 15:50:41 2358

原创 C语言 函数默认参数

这段代码也不知道谁是原创了,知道的话告诉我链接#include <stdio.h>#define DEFARG(name, defval) ((#name[0]) ? (name + 0 ) : defval)int _f1(int i){ return 2 * i;}#define f1(arg0) _f1(DEFARG(arg0, 0))int _f2(int i, int j)

2016-04-30 14:40:53 2446 1

原创 线性表的顺序存储结构(一)

不管三七二十一先贴代码 申明一下代码是参照李春葆《数据结构教程》修改#include <stdio.h>#include <stdlib.h>//C语言没有booleantypedef int bool; //这里的分号不要忘记了,宏定义不需要加分号#define true 1 #define false 0//利用宏来模拟参数默认值//C语言既不支持重载也不支持默认参数#d

2016-04-30 11:06:30 653

原创 Qt遍历ui窗口控件

//遍历UI中的QPushButtonMainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); QSignalMapper *mapper = new QSignalMapper(this); QObjec

2015-12-08 14:54:05 7250

原创 重载=运算符

测试代码如下#include <iostream>#include <string>using namespace std;class StupidClass{ int flag; string name; int* data;public: StupidClass(int flag, string name) : flag(flag), name(name){

2015-10-19 11:52:42 614

原创 二维数组作函数参数

欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl

2015-10-18 11:19:36 439

串口调试助手

串口调试助手

2017-05-15

二分查找_测试

二分查找_测试

2016-12-12

播放器源码

播放器源码

2014-08-29

从零开始学单片机C语言

从零开始学单片机C语言

2014-07-19

空空如也

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

TA关注的人

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