C++学习
文章平均质量分 84
小脆脆
我和我最后的倔强,握紧双手绝对不放
展开
-
C++读取txt中数据的两种方法
有时候,在程序编写过程中涉及到数据的读写,比如读入.txt文档中的数字,本文提供两种读入方法。一、利用数据流比如.txt中数据是如下格式:其中第一行代表有多少个二维数组,本例中是有3个二维数组,第二行代表每个二维数组有多少行,本例中二维数组的列数是固定不变的。那么如何读取这些二维数组呢?我的代码如下:#include#include#include#include原创 2017-06-05 13:19:32 · 16033 阅读 · 0 评论 -
leetcode_最长回文字符串
题目:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.我的答案:string longestPalindrome(string s) { int max_len = 0; int start =原创 2017-07-12 10:58:26 · 346 阅读 · 0 评论 -
leetcode_two sum()
最近觉得自己很渣,所以在这里立下flag,从今天开始每天刷一道leetcode上的题目,并且在这里进行代码整理,闲话少说,进入正题:一、Two sum题目要求:我的答案: vector twoSum(vector& nums, int target) { unordered_map hash; vector result; for (int i = 0;原创 2017-07-05 10:37:29 · 248 阅读 · 0 评论 -
leetcode_add_two_numbers
题目:我的答案:ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { int temp=0; ListNode a(0);//creat a new listnode and initialize it ListNode* p=&a; ListNode *q=p;原创 2017-07-05 11:33:04 · 236 阅读 · 0 评论 -
leetcode_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",原创 2017-07-05 11:35:47 · 213 阅读 · 0 评论 -
leetcode_median of two sorted arrays
题目:There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 =原创 2017-07-06 09:15:34 · 242 阅读 · 0 评论 -
leetcode_zigzag conversion
题目: leetcode_zigzagcoversion原创 2017-07-15 17:29:21 · 257 阅读 · 0 评论