- 博客(11)
- 收藏
- 关注
原创 Reverse a sentence
#include using namespace std;char sentence[] = "i like this program";//1.reverse all chars//2.rever only words.void revese_char(char* _string) { char* start = _string; char* end = start; w
2016-07-12 06:17:34
298
原创 String to Integer
int myAtoi(string str) { double x = 0; bool neg = false; int index = 0; int len = str.size(); bool foundNumber = false; while (index < len ) { //if str start with spaces if (str[index] ==
2016-05-12 04:18:16
321
原创 最大盛水量
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
2016-05-10 07:57:11
811
原创 randomize a vector
void shuffle(vector & vect, int size){ int i = 0; int temp = 0, index = size - 1; srand(time(nullptr)); while(index > 0){ i = rand() % (index + 1); temp = vect[in
2016-02-14 03:29:17
317
原创 Longest Palindromic Substring(最长回文子串)
string findLongestPalindrome(string & str){ size_t n = str.size(); size_t max_length = 0; size_t len = 0; size_t start = 0; if(n <= 1){ return str; } for(size_
2016-02-02 07:39:04
251
原创 3. Longest Substring Without Repeating Characters
int lengthOfLongestSubstring(string s) { int n = s.size(); if (n <= 1) { return n; } int i = 0;//start of the current checking string int j = 1;//end of the current checking string int len =
2016-01-28 15:53:48
304
原创 总结遍历二维数组的方式
#include #include #include #include #include using namespace std;int tl(){ return 2;}int main(){ constexpr int row = 2, col = 3; int arr[row][col] = {1,2,3,4,5,6}; for
2016-01-24 09:05:29
417
原创 2 - Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link
2016-01-22 13:44:32
205
原创 1 - Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where
2016-01-22 12:21:21
263
原创 OpenGL学习笔记(一)
#include #include static GLfloat spin = 0.0;void init(){ glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT);}void display(){ glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glRotatef(spin, 0.0, 0.0
2014-03-02 23:59:53
542
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人