自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LEETCODE--Single Number

Given an array of integers, every element appears twice except for one. Find that single one. 数值相同的两个数进行或异运算之后得到各位全部为0,非零数与全零数或异运算之后得到此数本身class Solution { public: int singleNumber(vector<int>& num

2017-01-31 18:42:43 247

原创 LEETCODE--Island Perimeter

You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely s

2017-01-31 11:44:17 197

原创 LEETCODE-- Find All Numbers Disappeared in an Array

Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array. Could

2017-01-31 11:31:13 141

原创 LEETCODE--Reverse String

Write a function that takes a string as input and returns the string reversed. Example: Given s = “hello”, return “olleh”. class Solution { public: string reverseString(string s) { int le

2017-01-26 10:59:02 181

原创 LEETCODE--Fizz Buzz

Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For

2017-01-26 09:53:52 278

原创 LEETCODE--Number Complement

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fit within the range of a 32

2017-01-16 17:07:16 388

原创 LEETCODE--Max Consecutive Ones

Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecutive 1

2017-01-16 16:00:21 345

原创 LEETCODE--Hamming Distance

The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Note: 0 ≤ x, y < 231.

2017-01-16 13:56:40 169

转载 C++ 按位与、或、异或等运算方法

转载自 按位与运算符(&) 参加运算的两个数据,按二进制位进行“与”运算。 运算规则:0&0=0; 0&1=0; 1&0=0; 1&1=1; 即:两位同时为“1”,结果才为“1”,否则为0 例如:3&5 即 0000 0011 & 0000 0101 = 0000 0001 因此,3&5的值得1。另,负数按补码形式参加按位与运算。 “与运算”的特殊用

2017-01-16 11:58:49 400

原创 3-3竖式问题

题目:找出所有形如abc*de(三位数乘以两位数)的算式,使得在完整的竖式中,所有数字都属于一个特定的数字集合。输入数字集合(相邻数字之间没有空格),输出所有竖式。每个竖式前应有编号,之后应有一个空行。最后输出解的总数。具体格式见样例输出(为了便于观察,竖式中的空格改用小数点显示,但你的程序应该输出空格,而非小数点)。样例输入:2357样例输出:<1>..775X..33.23252325.2557

2017-01-13 20:22:32 562

原创 C++输出格式控制

cout.precision()设置小数点后精确度, cout.width()设置宽度, cout.setf()设置显示格式, 比如cout.setf(ios::left)左对齐、 cout.setf(ios::showpoint)不管是否有小数位,显示小数点、 cout.fill();不足宽度则填充,如cout.fill(‘0’);

2017-01-11 20:48:16 231

原创 3-2蛇形填数

蛇形填数:在n*n的方阵里填入1,2,3,…,n*n,要求添成蛇形。其中n<=8。例如n=4时的方阵为: 10 11 12 1 9 16 13 2 8 15 14 3 7 6 5 4 自己写的代码: 有点麻烦#include<iostream> using namespace std; #define MAX 10 int sn

2017-01-11 20:41:41 269

原创 3-1开灯问题

有n盏灯,编号为1~n,第1个人把所有灯打开,第2个人按下所有编号为2的倍数的开关(这些灯将被关掉),第3个人按下所有编号为3的倍数的开关(其中关掉的灯被打开, 开着灯将被关闭),依此类推。一共有k个人,问最后有哪些灯开着? 输入:n和k,输出开着的灯编号。k≤n≤1000。 样例输入:7 3 样例输出:1 5 6 7#include<iostream> us

2017-01-11 17:07:09 288

空空如也

空空如也

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

TA关注的人

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