导航

04 2016 档案

摘要:将一个四位数的整数,输出它的拼音形式。如1001,输出“yiqianlingyi”,10,输出“10” 阅读全文

posted @ 2016-04-25 23:11 CSU蛋李 阅读(272) 评论(0) 推荐(0)

摘要:输入例句:S1="计算语言学课程有意思" ; 定义:最大词长MaxLen = 5;S2= " ";分隔符 = “/”; 假设存在词表:…,计算语言学,课程,意思,…; 最大逆向匹配分词算法过程如下: (1)S2="";S1不为空,从S1右边取出候选子串W="课程有意思"; (2)查词表,W不在词表中 阅读全文

posted @ 2016-04-19 17:52 CSU蛋李 阅读(1943) 评论(0) 推荐(1)

摘要:定义Quote和Bulk_Quote的拷贝控制成员,令其与合成的版本行为一致。为这些成员以及其他构造函数添加打印状态的 语句,使得我们能够知道正在运行哪个程序。使用这些类编写程序,预测程序将创建和销毁哪些对象。重复实验,不断比较你 的预测和实际输出结果是否相同,直到预测完全准确再结束。 阅读全文

posted @ 2016-04-17 18:18 CSU蛋李 阅读(203) 评论(0) 推荐(0)

摘要:// 15_15.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include #include using namespace std; class Quote { public: Quote() = default; Quote(const string &book,double p):bookNo(book),price(p)... 阅读全文

posted @ 2016-04-17 01:16 CSU蛋李 阅读(157) 评论(0) 推荐(0)

摘要:编写一个简单的桌面计算器使其处理二元运算 阅读全文

posted @ 2016-04-16 18:00 CSU蛋李 阅读(293) 评论(0) 推荐(0)

摘要:Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 阅读全文

posted @ 2016-04-14 00:49 CSU蛋李 阅读(186) 评论(0) 推荐(0)

摘要:13.44:编写标准库string类的简化版本,命名为String。你的类应该至少有一个默认构造函数和一个接受C 风格字符串指针参数的构造函数。使用allocator为你的String类分配所需内存 String.h头文件 主函数验证 阅读全文

posted @ 2016-04-13 20:21 CSU蛋李 阅读(187) 评论(0) 推荐(0)

摘要:C++primer 练习13.39 编写你自己版本的StrVec,包括自己版本的reserve,capacity(参见9.4节,第318页)和resize(参见9.3.5节,第314页) 13.40 为你的StrVec类添加一个构造函数,它接受一个initializer_list 阅读全文

posted @ 2016-04-13 19:33 CSU蛋李 阅读(337) 评论(0) 推荐(0)

摘要:#pragma once #include #include using namespace std; class Message { friend class Folder; friend void swap(Message &lhs, Message &rhs); public: explicit Message(const string &str=""):cont... 阅读全文

posted @ 2016-04-13 17:00 CSU蛋李 阅读(224) 评论(0) 推荐(0)

摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文

posted @ 2016-04-13 14:51 CSU蛋李 阅读(104) 评论(0) 推荐(0)

摘要:Given a column title as appear in an Excel sheet, return its corresponding column number. For example: 阅读全文

posted @ 2016-04-13 14:50 CSU蛋李 阅读(99) 评论(0) 推荐(0)

摘要:Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. 采用三 阅读全文

posted @ 2016-04-13 14:40 CSU蛋李 阅读(94) 评论(0) 推荐(0)

摘要:Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 给一个数n,看他的阶乘中最后有几个0 10是由5 阅读全文

posted @ 2016-04-12 23:59 CSU蛋李 阅读(113) 评论(0) 推荐(0)

摘要:// 12_27.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include #include #include #include #include #include #include #include using namespace std; //提前声明类QueryResult,在书中说必须提前声明,然而vs2015中 //仅声明友元... 阅读全文

posted @ 2016-04-10 21:51 CSU蛋李 阅读(238) 评论(0) 推荐(0)

摘要:编写函数,返回一个动态分配的int的vector。将此vector传递给另一个函数,这个函数读取标准输入,将读入的值 保存在vector元素中。再将vector传递给另一个函数,打印读入的值。记得在恰当的时刻delete vector 阅读全文

posted @ 2016-04-08 01:23 CSU蛋李 阅读(155) 评论(0) 推荐(0)

摘要:// 11_33.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include #include #include #include #include using namespace std; //用map文件来建立一个要转换的字符串对应的转换成的字符串 map buildMap(ifstream &map_file) { map ma; ... 阅读全文

posted @ 2016-04-05 18:21 CSU蛋李 阅读(212) 评论(0) 推荐(0)

摘要:Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), retur 阅读全文

posted @ 2016-04-05 03:06 CSU蛋李 阅读(161) 评论(0) 推荐(0)

摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit 阅读全文

posted @ 2016-04-05 02:22 CSU蛋李 阅读(84) 评论(0) 推荐(0)

摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文

posted @ 2016-04-05 02:12 CSU蛋李 阅读(139) 评论(0) 推荐(0)

摘要:春节期间小明使用微信收到很多个红包,非常开心。在查看领取红包记录时发现,某个红包金额出现的次数超过了红包总数的一半。请帮小明找到该红包金额。写出具体算法思路和代码实现,要求算法尽可能高效。 给定一个红包的金额数组gifts及它的大小n,请返回所求红包的金额。 测试样例: 阅读全文

posted @ 2016-04-01 13:00 CSU蛋李 阅读(172) 评论(0) 推荐(0)

摘要:当n=1时,“0”,“1”; 当n=2时,“00”,“01”,“11”,“10“; 当n=3时,“000”,“001”,“011”,“010”,“110”,“111”,“101”,“100”; 由此可以看出,每次向下递归调用时,总是在原来的字符串的基础上加“0”,“1”,“1”,“0“,”0“,”1 阅读全文

posted @ 2016-04-01 12:37 CSU蛋李 阅读(213) 评论(0) 推荐(0)

摘要: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 intege 阅读全文

posted @ 2016-04-01 01:07 CSU蛋李 阅读(128) 评论(0) 推荐(0)

摘要:Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 -- 阅读全文

posted @ 2016-04-01 00:35 CSU蛋李 阅读(111) 评论(0) 推荐(0)