牛客790167564号
牛客790167564号
全部文章
分类
归档
标签
去牛客网
登录
/
注册
牛客790167564号的博客
全部文章
(共48篇)
题解 | #单组_保留小数位数#
格式输出,你值得拥有 #include <iostream> using namespace std; int main() { double a; cin>>a; printf("%.3lf",a); return 0;...
2024-08-09
12
146
题解 | #多组_带空格的字符串_T组形式#
这并不难,但是一定要注意:要用getline!!! 还有一点更重要的:它会先读入字符串长度再读字符串,所以一定要用getchar吃掉回车!!! #include <iostream> using namespace std; int main() { string s; ...
2024-08-09
10
215
题解 | #倒置字符串#
巧妙的利用了输入以空格隔开的设定,于是字符串数组存一下倒序输出就完事了 #include <iostream> #include <vector> using namespace std; int main() { vector<string>s; ...
2024-08-07
0
143
题解 | #输出水仙花数#
巨短,巨简单的代码 #include <iostream> using namespace std; int main() { for(int i=100;i<1000;i++){ int a=i%10,b=i/10%10,c=i/100%10;//剥离每...
2024-08-05
0
107
题解 | #找到数组里的第k大数(C++)#
直接排序输出就OK,很暴力(反正这题数据弱得很) #include<bits/stdc++.h> using namespace std; int main(){ int n,k; vector<int>a; cin>>n>>k; for(in...
2024-08-05
0
120
题解 | #使用算法#
algorithm头文件是使用STL算法必备的,不加就别想用sort了。 #include <iostream> #include <vector> #include <algorithm> using namespace std; bool cmp(int a,...
2024-08-05
0
114
题解 | #利用指针遍历数组#
数组名是数组首地址,加上i就是第i个元素的值啦!顺便提一句,指针的运算比int类型快,可以解决一部分卡常(把i换成指针) #include <iostream> using namespace std; int main() { int arr[6] = { 0 }; ...
2024-08-04
0
125
题解 | #求长方体表面积#
这里要注意一点,获取基类的area时,一定要加rectangle::,派生类中函数名和基类相同时,基类的函数会被覆盖(shadow),不标明命名空间就会构成递归死循环 #include<bits/stdc++.h> using namespace std; class rectangle...
2024-08-04
0
126
题解 | #多态实现求面积体积#
父类用虚函数,子类再覆写一遍,这样也可以是多态 #include<bits/stdc++.h> using namespace std; class rectangle{ private: int length,width; public: rectangle(int x,i...
2024-08-04
0
129
题解 | #多态实现计算器功能#
纯虚函数的解法如何?(动多态) #include <iostream> using namespace std; class BaseCalculator { public: int m_A; int m_B; virtual i...
2024-08-04
0
139
首页
上一页
1
2
3
4
5
下一页
末页