自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 2的幂 leetcode C++

个人解题思路: class Solution { public: bool isPowerOfTwo(int n) { if (n == 1) return true; else if (n == 0) return false; else if (n%2 == 1) return false; else return isPowerOfTwo(n/2);

2021-05-30 14:10:10 87

原创 两数之和 C++ Leetcode

原解题思路: class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { vector <int> result; for(int i = 0; i < nums.size(); i++){ int num2 = target - nums[i]; for (int j = i+

2021-05-29 16:57:38 78

原创 C++ 动态分配的strcyp函数

#include <iostream> using namespace std; //count length of char array int strlen(char* str) { int i = 0; while (*str++ != '\0') { i++; } return i; } // required copy string function char* copyCString(char* str) { int size = strlen(str); cha

2021-04-04 01:25:39 162

原创 汉诺塔移动次数 递归 C++

#include <iostream> using namespace std; void moveonetower(char start, char finish, int& count) { cout << start << "->" << finish << endl; } void movetower(int n, char start, char finish, char tmp, int& count) {

2021-03-18 15:10:24 437

原创 c++递归实现字符串倒序

#include <iostream> #include <string> using namespace std; string reverse(string& str) { if (str.length() <= 1) return str; else { string sub = str.substr(1, str.length() - 2); return str[str.length() - 1] + reverse(sub) + str[0];

2021-03-14 16:45:52 610

原创 c++递归 求一个整数的各个数字之和

int digitsum(int n) { if (n < 10) return n; else return (n % 10) + digitsum(n / 10); }

2021-03-14 13:35:48 501

原创 C++最大公约数 欧几里得算法

#include <iostream> using namespace std; int gcd(int x, int y) { if (x % y == 0) return y; else { return gcd(y, x % y); } }

2021-03-14 13:30:42 280

原创 C++ vector 读取一组数并求平均值和标准差

#include <iostream> #include <vector> #include <string> using namespace std; double mean(vector <double>& data); double stddev(vector <double>& data); int main() { double v; vector <double> data; cout <&l

2021-03-10 14:32:56 1572 2

原创 C++程序设计 基础、编程抽象与算法策略 第三章习题

#include <iostream> #include <string> using namespace std; bool endWith(string str, string suffix) { int a = str.length(); int b = suffix.length(); if (a < b) return false; for (int i = 0; i < b; i++) { if (str[a - i - 1] != suf...

2021-02-27 18:01:22 208

原创 C++程序设计 基础、编程抽象与算法策略 第二章习题

#include <iostream> using namespace std; int roundToNearstInt(double x) { int y; if (x >= 0) { y = x + 0.5; } else { y = x - 0.5; } return y; } int main() { double x; cout << "Enter the number: "; cin >> x; int y = ro...

2021-02-23 13:05:13 187

原创 C++程序设计 基础、编程抽象与算法策略 第一章习题

C++程序设计 基础、编程抽象与算法策略 第一章习题 5. #include <iostream> using namespace std; const int SENTINEL = 0; int main() { cout << "This program fins the largest interger in a list." << endl; cout << "Use " << SENTINEL << " to

2021-02-13 18:09:12 342 1

空空如也

空空如也

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

TA关注的人

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