- 博客(7)
- 收藏
- 关注
原创 寒假刷题<LeetCode><PAT>笔记、总结,C++语言
写在前面 寒假备考考研复试,上机/C/C++笔试,写此文章,以记录一些重点,基本/中级算法,题目、解题思路、代码等。如有错误,欢迎各位大佬指正。 C++ 容器、STL 整理集合 (部分摘自网络,不做商业用途,仅学习使用) vector 定义:向量(Vector)是一个封装了动态大小数组的顺序容器(Sequence Container)。跟任意其它类型容器一样,它能够存放各种类型的对象。可以简单的认...
2020-01-16 10:11:11 508
原创 LeetCode 全排列问题(中级算法-回溯算法)C++解法
题目描述 给定一个没有重复数字的序列,返回其所有可能的全排列。 示例: 输入: [1,2,3] 输出: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] 思路 全排列函数 qpl,传入一个参数n,代表当前交换的首元素,然后遍历交换其与剩下的元素,每次交换之后,调用qpl函数,传入n+1,即 qpl 目前交换元素后剩下的位数的全排列,然...
2020-01-16 09:12:26 315
原创 1059 Prime Factors (25 分) Rookie Hyg
代码 #include<bits/stdc++.h> using namespace std; int isSu(int a) { if(a==1) return 0; else { int sqr = (int)sqrt(a*1.0); for(int i = 2; i<=sqr; i++) ...
2019-07-18 22:16:13 115
原创 1024 Palindromic Number (25 分) From Rookie Hyg
CODE #include <bits/stdc++.h> using namespace std; string add(string s) { string q = s; reverse(s.begin(),s.end()); int len = q.length(); int add=0; for(int i = len-1;i>...
2019-07-14 20:20:01 157
原创 1025 PAT Ranking (25 分) From Rookie Hyg
代码 #include<bits/stdc++.h> using namespace std; struct Student { char no[15]; int score; int local_num; int local_rank; int all_rank; } stu[30030]; bool cmp(Student A, Studen...
2019-07-10 23:35:38 105
原创 PAT甲级 1002 A+B for Polynomials (25 分) From rookie_Hyg
题目描述 分析 就是求和啊。注意: ①系数为0不输出 ②系数保留一位小数 代码 #include <bits/stdc++.h> using namespace std; int main() { int k1,k2; scanf("%d",&k1); double a[k1*2]; for(int i = 0; i<k1*2; i++)...
2019-06-27 23:08:09 103
原创 PAT 1001 A+B Format From rookie_Hyg
题目描述 Calculate a+b and output the sum in standard format – that is, the digits must be separated into groups of three by commas (unless there are less than four digits). Input Specification: Each inpu...
2019-04-08 19:55:10 157
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人