摘要: 1、使用时加入头文件#include <map>; 2、从前遍历it = map.begin(); it != map.end(); it++ 3、从后遍历it = map.rbegin(); it != map.rend(); it++ 4、map.end() -- 不一定指向最后一个元素,指向最 阅读全文
posted @ 2020-03-23 00:09 AlsoRan 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 1、请输入字符串,最多输入4 个字符串,要求后输入的字符串排在前面,例如 输入:EricZ 输出:1=EricZ 输入:David 输出:1=David 2=EricZ 输入:Peter 输出:1=Peter 2=David 3=EricZ 输入:Alan 输出:1=Alan 2=Peter 3=D 阅读全文
posted @ 2020-03-21 23:41 AlsoRan 阅读(321) 评论(0) 推荐(0) 编辑
摘要: 1、存储一组姓名,如Apple Tom Green Jack要求能排序、按字母顺序插入、并显示。 #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { string s 阅读全文
posted @ 2020-03-21 21:32 AlsoRan 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 1、一个小球,从高为H的地方下落,下落弹地之后弹起高度为下落时的一半,比如第一次弹起高度为H/2,如此反复,计算从小球H高度下落到n次弹地往返的总路程。 #include <iostream> #include <cmath> using namespace std; int h; double c 阅读全文
posted @ 2020-03-21 21:07 AlsoRan 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 1、写一个程序判断字符串中数字的位置. 例如:输入 a3b4c5 输出 2 4 6 #include <iostream> using namespace std; int main() { string s; while(cin >> s) { for (int i = 0; i < s.leng 阅读全文
posted @ 2020-03-21 15:29 AlsoRan 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 1、给定一个程序,关于字符串的,要求输入并调试,说出此程序的意图。意图是按字母顺序对两个字符串比较排序。 第二问要求用尽可能少的语句对该程序进行修改,使其能够对两个字符串比较长度排序。 #include <iostream> #include <algorithm> using namespace 阅读全文
posted @ 2020-03-21 00:42 AlsoRan 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 1、建立一个角类,在这个类中重载减号运算符,并实现求出角度的正弦值的函数。 #include <iostream> #include <cmath> using namespace std; class angel { public: double x1, x2; double getangel() 阅读全文
posted @ 2020-03-20 21:13 AlsoRan 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 1、输入球的中心点和球上某一点的坐标,计算球半径和体积。 #include <iostream> #include <cmath> using namespace std; int main() { int x0, y0, z0, x, y, z; cout << "请输入球心坐标:"; cin > 阅读全文
posted @ 2020-03-18 23:15 AlsoRan 阅读(314) 评论(0) 推荐(0) 编辑
摘要: 1、某人有8 角的邮票5 张,1 元的邮票4 张,1 元8 角的邮票6 张,用这些邮票中的一张或若干张可以得到多少中不同的邮资? #include <iostream> #include <set> using namespace std; int main() { set<int> s; int 阅读全文
posted @ 2020-03-18 20:47 AlsoRan 阅读(259) 评论(0) 推荐(0) 编辑
摘要: 1、请输入高度 h,输入一个高为 h,上底边长为 h的等腰梯形(例如 h=4,图形如下)。 **** ****** ******** ********** #include <iostream> using namespace std; int main() { int h; while(cin > 阅读全文
posted @ 2020-03-18 18:25 AlsoRan 阅读(299) 评论(0) 推荐(0) 编辑