摘要: #if 1 #include <iostream> #include <vector> #include <algorithm> using namespace std; vector<int> add(vector<int> A, vector<int> B) { vector<int> C; i 阅读全文
posted @ 2023-09-20 10:02 karinto 阅读(39) 评论(0) 推荐(0)
摘要: 1、整数二分 以acwing 789为例,题目要求如下: 第一行输入整数n和q,表示数组长度和询问个数。 第二行输入数组,包含n个整数。 接下来q行,每一行一个整数k,表示一个问询元素。 要求输出q行,每行包含两个整数,表示所求元素的起始位置和终止位置。 如果数组中不存在该元素,则返回 -1 -1。 阅读全文
posted @ 2023-09-16 20:20 karinto 阅读(51) 评论(0) 推荐(0)
摘要: 1、快速排序 #include <iostream> using namespace std; const int N = 1e5 + 10; int n, q[N]; void qksort(int q[], int l, int r) { if (l >= r) return; int x = 阅读全文
posted @ 2023-09-16 20:00 karinto 阅读(28) 评论(0) 推荐(0)
摘要: 1、Two Sum Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume tha 阅读全文
posted @ 2023-06-27 17:33 karinto 阅读(21) 评论(0) 推荐(0)
摘要: 示例1:函数与local局部变量的使用 #!/bin/bash foo1=hello foo2=world echo "$foo1" #双引号里的变量转义, 输出hello echo '$foo1' #单引号里的变量不会被转义, 直接输出$foo1 mcd(){ echo -n "$0 " #-n 阅读全文
posted @ 2023-03-11 09:42 karinto 阅读(55) 评论(0) 推荐(0)
摘要: 示例1:截取http响应报文中的信息 karinto@server:/home/karinto$ curl --head --silent www.baidu.com > baidu #head请求(不返回请求对象), 将得到的http响应报文信息输出到baidu文件中 karinto@server 阅读全文
posted @ 2023-03-10 17:34 karinto 阅读(54) 评论(0) 推荐(0)
摘要: //Fraction.h #pragma once #include <iostream> #include <string> using namespace std; int& __gcd(int&, int&); class Fraction { public: explicit Fractio 阅读全文
posted @ 2023-02-27 00:38 karinto 阅读(75) 评论(0) 推荐(0)
摘要: //string.h #pragma once class String { public: String(const char* cstr = 0); String(const String& str); ~String(); String& operator = (const String& s 阅读全文
posted @ 2023-02-22 02:02 karinto 阅读(22) 评论(0) 推荐(0)
摘要: //complex.h #ifndef __MYCOMPLEX_H__ #define __MYCOMPLEX_H__ class complex; complex& __doapl(complex*, const complex&); //友元可以在类外声明 complex& __doami(co 阅读全文
posted @ 2023-02-21 11:17 karinto 阅读(50) 评论(0) 推荐(0)