![](https://img-blog.csdnimg.cn/20190918140053667.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
查找元素
1.直接遍历
2.二分查找
Greylan
练习用。
展开
-
A1036
Boys vs Girls(25分)总结:最低M分数初始化为101,最高F分数初始化为-1;因为分数范围[0,100],0和100可以取到。代码:#include <iostream>#include <cstring>using namespace std;int main(){ int n, grade, max=-1, min=101 ;//初始化 char gender; string name, id, maxname="Absent", .原创 2020-07-07 14:38:42 · 87 阅读 · 0 评论 -
A1006
Sign In and Sign Out(25分)单词:总结:代码:#include <cstdio>int main(){ return 0;}原创 2020-07-07 13:43:25 · 65 阅读 · 0 评论 -
A1011
World Cup Betting(20分)单词:odds: 概率,投注赔率 The winner's odd would bethe product of the three odds times 65%: 赢家的赔率是(选择的)三个赔率的乘积再乘以65%总结:边输入边输出:一组数据(一行三个数)输入完毕, 立即输出三个数中最大的,并进行累乘。 max初值取0.65 或者 1.0需要再*0.65。代码:#include <cstdio> double Fi...原创 2020-07-06 22:25:48 · 93 阅读 · 0 评论 -
B1028
人口普查(20分)总结: 使用string类型存储出生年月,可以直接比较大小。string大小:从前向后,比较字典序。代码:#include <iostream>#include <cstring>using namespace std; int main(){ int n, cnt=0; string birth, first = "1814/09/05", last = "2014/09/07"; //yyyy/mm/dd格式 stri...原创 2020-07-06 19:49:20 · 81 阅读 · 0 评论 -
B1004
成绩排名(20分)总结:代码:#include <cstdio>int main(){ return 0;}原创 2020-07-06 16:14:41 · 94 阅读 · 0 评论 -
B1041
考试座位号(15分)总结:涉及三个数据,都为整型: ①二维数组:两个做下标,一个存储在数组内。 ...原创 2020-07-05 22:14:04 · 127 阅读 · 0 评论 -
B1032
挖掘机技术哪家强(20分)总结:按照题目要求, 定义最大参赛人数MAXN, 直接分配出长度MAXN的数组空间。 使用动态数组vector,必须有头文件#include<vector>和using namespace std;。代码:#include<cstdio>#include<vector>using namespace std;//const int MAXN = 100001;int main(){ int n; sca...原创 2020-07-02 21:53:37 · 94 阅读 · 0 评论