04 2023 档案

摘要:1 #include<iostream> 2 #include<string> 3 using namespace std; 4 //assign 5 void test01() 6 { 7 string str1; 8 //截取三个字符 9 str1.assign("hello,world", 3 阅读全文
posted @ 2023-04-29 13:30 aallofitisst 阅读(12) 评论(0) 推荐(0)
摘要:1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 5 6 void test() 7 { 8 vector<vector<int>>v; 9 vector<int> v1; 10 vector<int> v2; 11 阅读全文
posted @ 2023-04-27 21:24 aallofitisst 阅读(24) 评论(0) 推荐(0)
摘要:范围for循环的语法形式为for (declaration : range),其中declaration是一个声明语句,用于定义一个变量,range是一个表达式,表示要遍历的范围。 在每次循环迭代中,范围for循环会从range中取出一个元素,并用它来初始化declaration中定义的变量。然后执 阅读全文
posted @ 2023-04-27 20:42 aallofitisst 阅读(30) 评论(0) 推荐(0)
摘要:template<class T> class myarr { int capacity; int size; T* arr; public: myarr(int a) { arr = new T[a]; size = 0; capacity = a; } myarr(myarr<T>& a) { 阅读全文
posted @ 2023-04-25 22:53 aallofitisst 阅读(12) 评论(0) 推荐(0)
摘要:给定 s 和 t 两个字符串,当它们分别被输入到空白的文本编辑器后,如果两者相等,返回 true 。# 代表退格字符。 注意:如果对空文本输入退格字符,文本继续为空。 示例 1: 输入:s = "ab#c", t = "ad#c"输出:true解释:s 和 t 都会变成 "ac"。示例 2: 输入: 阅读全文
posted @ 2023-04-24 23:03 aallofitisst 阅读(26) 评论(0) 推荐(0)
摘要:给定一个已排序的链表的头 head , 删除原始链表中所有重复数字的节点,只留下不同的数字 。返回 已排序的链表 。 示例 1: 输入:head = [1,2,3,3,4,4,5]输出:[1,2,5]示例 2: 输入:head = [1,1,1,2,3]输出:[2,3] 提示: 链表中节点数目在范围 阅读全文
posted @ 2023-04-21 12:53 aallofitisst 阅读(57) 评论(0) 推荐(0)
摘要://已知中文字符占用两个字节#include <stdio.h> #include <string.h> bool judge(char* a, int& i, int& k); int main() { int i, k; char a[100]; while (scanf("%s", a) != 阅读全文
posted @ 2023-04-20 18:25 aallofitisst 阅读(157) 评论(0) 推荐(0)
摘要:class People { protected: int age; string name; public: People() {} People(int a, string n) : age(a), name(n) {} virtual ~People() {} void setValue(in 阅读全文
posted @ 2023-04-19 21:44 aallofitisst 阅读(19) 评论(0) 推荐(0)
摘要:class Complex { double real; double imag; public: friend istream& operator>>(istream& is, Complex& c); friend ostream& operator <<(ostream& os, const 阅读全文
posted @ 2023-04-18 20:12 aallofitisst 阅读(22) 评论(0) 推荐(0)
摘要:#include<iostream> using namespace std; class Counter { friend Counter& operator +(const Counter& a, const Counter& b); int num; public: Counter() { n 阅读全文
posted @ 2023-04-17 21:47 aallofitisst 阅读(23) 评论(0) 推荐(0)
摘要:include<iostream> #include<fstream> using namespace std; #include<string> void test01() { string l; ofstream a; a.open("test.txt", ios::out); /*getlin 阅读全文
posted @ 2023-04-16 16:44 aallofitisst 阅读(9) 评论(0) 推荐(0)
摘要:编写一个高效的算法来判断 m x n 矩阵中,是否存在一个目标值。该矩阵具有如下特性: 每行中的整数从左到右按升序排列。每行的第一个整数大于前一行的最后一个整数。 示例 1: 输入:matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 阅读全文
posted @ 2023-04-12 17:22 aallofitisst 阅读(18) 评论(0) 推荐(0)