05 2022 档案

 
不使用+-*/实现数字的加减
摘要:int add(int x, int y) { int sum = 0; int temp = 1; while (temp) { sum = x ^ y;//异或,半加 temp = (x & y) << 1;//与运算后,左移一位 x = sum; y = temp; } return x;}i 阅读全文
posted @ 2022-05-25 17:26 echojojo 阅读(48) 评论(0) 推荐(0)
双指针法删除元素,保证时间复杂度O(n)
摘要:#include<iostream>#include<cmath>#include<vector>using namespace std;class Solution {public: int removeElement(vector<int>& nums, int val) { int slowI 阅读全文
posted @ 2022-05-25 17:24 echojojo 阅读(33) 评论(0) 推荐(0)
给定三角形 ABC 和一点 P(x,y,z),判断点 P 是否在 ABC 内
摘要:struct point { float x; float y;}; //求取三角形面积,1/2*AB*AC float Area(const point p1,point p2,point p3) { point AB, BC; AB.x = p1.x - p2.x; BC.x = p3.x - 阅读全文
posted @ 2022-05-23 15:47 echojojo 阅读(61) 评论(0) 推荐(0)