上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 36 下一页
摘要: C++代码如下: #include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <numeric> using namespace std; bool DFS(vector<int> &num 阅读全文
posted @ 2020-07-29 17:36 repinkply 阅读(199) 评论(0) 推荐(0)
摘要: 输入输出格式一定要与样例一样,连一个空格,逗号都不能少,否者就会报错。 C++代码如下: #include <iostream> #include <vector> #include <string> #include <map> using namespace std; int main() { 阅读全文
posted @ 2020-07-29 16:32 repinkply 阅读(569) 评论(0) 推荐(0)
摘要: C++代码如下: #include <iostream> #include <iomanip> using namespace std; int main() { int n = 0; while (cin >> n) { int count = 0; int negativeCount=0; do 阅读全文
posted @ 2020-07-29 12:02 repinkply 阅读(459) 评论(0) 推荐(0)
摘要: C++代码如下: #include <iostream> #include <string> #include <cctype> using namespace std; int main() { string str = ""; while (cin >> str) { if (isdigit(s 阅读全文
posted @ 2020-07-28 21:55 repinkply 阅读(359) 评论(0) 推荐(0)
摘要: 一:解题思路 Time:O(n*log(n)) Space:O(n) 二:完整代码示例 (C++版和Java版) #include <iostream> #include <vector> #include <string> #include <map> #include <algorithm> u 阅读全文
posted @ 2020-07-28 16:36 repinkply 阅读(285) 评论(0) 推荐(0)
摘要: 一:解题思路 这道题目和 leetcode69 题,求解x的平方根有些类似。都是采用二分的思想来做,可以对比分析。 二:完整代码示例 (C++版和Java版) C++: #include <iostream> using namespace std; double getCubeRoot(doubl 阅读全文
posted @ 2020-07-26 20:53 repinkply 阅读(370) 评论(0) 推荐(0)
摘要: 这个题目有点类似leetcode上面的,62和63题。 题目:给定一个M行N列的矩阵(M*N个格子),每个格子中放着一定数量的平安果。你从左上角的各自开始,只能向下或者向右走,目的地是右下角的格子。每走过一个格子,就把格子上的平安果都收集起来。求你最多能收集到多少平安果。注意:当经过一个格子时,需要 阅读全文
posted @ 2020-07-26 18:30 repinkply 阅读(321) 评论(0) 推荐(0)
摘要: 等式变换输入一个正整数X,在下面的等式左边的数字之间添加+号或者-号,使得等式成立。1 2 3 4 5 6 7 8 9 = X比如:12-34+5-67+89 = 51+23+4-5+6-7-8-9 = 5请编写程序,统计满足输入整数的所有整数个数。输入: 正整数,等式右边的数字输出: 使该等式成立 阅读全文
posted @ 2020-07-26 17:39 repinkply 阅读(153) 评论(0) 推荐(0)
摘要: 去除重复字符并排序。 输入:字符串 输出:去除重复字符并排序的字符串 样例输入: ebbaabaacdefff 样例输出: abcdef 程序如下: void removeDuplicateAndSort(string& s) { if (s.length() == 0) return; sort( 阅读全文
posted @ 2020-07-26 17:08 repinkply 阅读(101) 评论(0) 推荐(0)
摘要: 第一题(60分): ​ 按要求分解字符串,输入两个数M,N;M代表输入的M串字符串,N代表输出的每串字符串的位数,不够补0。例如:输入2,8, “abc” ,“123456789”,则输出为“abc00000”,“12345678“,”90000000” 程序如下: void dfs(string 阅读全文
posted @ 2020-07-26 16:54 repinkply 阅读(135) 评论(0) 推荐(0)
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 36 下一页