- 博客(9)
- 收藏
- 关注
原创 Assign Cookies
#include<vector> #include<algorithm> class Solution { public: int find(std::vector<int>& q, std::vector<int>& s) //这里的& 是引用的意思 { std::sort(q.begin(), q.end()); ...
2019-04-08 23:25:06
93
原创 Valid Pailndrome
Note: For the purpose of this problem, we define empty string as valid palindrome. class Solution { public: bool palindrome(string s) { transform(s.begin(), s.end(), s.begin(), ::tolower); aut...
2019-04-08 00:05:46
70
原创 Remove Duplication from Sorted Array
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this by modifyin...
2019-04-06 00:06:20
78
原创 two sum
public: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int,int> hash; for(int i=0;i<nums.size();++i) { int t=target-nums[i];...
2019-04-01 20:55:12
77
原创 acm第一次考试题目重写
#include<iostream> using namespace std; int main() { int M; cin>>M; double A,B,C; for(int i=0;i<M;i++) { cin>>A>>B>>C; if(A+B>C&&A+C>B&
2018-12-10 00:07:47
118
原创 第6题
这题考察排序,我采用冒泡排序,用数组来存要输入的字符;刚开始我一时好奇用来cin.get 来输入字符,后来发现我还要想办法取消空格符,自找麻烦。还有两个数比较交换时,我忘记加&了,结果只交换了形参。额,以后要记得地址交换和引用交换 #include using namespace std; #include <stdio.h> void swap(char &x,ch...
2018-12-07 21:21:08
158
原创 第七题
虽然c++从c中发展来的,但是觉得这种情况c中printf("%0.Mf",a); /*将M改为你想保留的几位小数 */更好表示 在这里插入代码片 ```#include<iostream> #include <iomanip> using namespace std; #define PI 3.1415927 double volume(double radius...
2018-12-07 18:21:33
99
原创 第8题
#include<iostream> using namespace std; int main() { int a,b; While(cin>>a>>b) if((a+b)%86==0) cout<<"Yes"<<endl; else cout<<"No"<&a
2018-12-07 17:18:41
163
原创 第四题
这题有给答案,也是最简单的一题。唯一的难点是怎么表示多行输入后多行输出。有想过用循环让结果返回,可是没有成功,从这道题学到while的妙用,也不亏了 #include<iostream> using namespace std; int main() { double A,B ; while(cin>>A>>B) { cout<<A+B...
2018-12-07 17:13:53
78
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人