数组使用find查询用法
#include "stdafx.h"
#include <string>
#include <list>
#include <algorithm>
#include <iostream>
using namespace std;
class Student
{
public:
Student(){}
Student(string name,string sex,int age,string number);
int getAge(){return _age;}
string getNumber(){return _number;}
bool operator==(const string&str)//重载操作符
{
return str==_number;
}
bool operator==(const int&stemp)
{
return stemp==_age;
}
private:
string _name;
string _sex;
int _age;
string _number;
};
Student::Student(string name,string sex,int age,string number)
{
_name=name;
_sex=sex;
_age=age;
_number=number;
}
int _tmain(int argc, _TCHAR* argv[])
{
Student st[5]={
Student("la","男",12,"122"),
Student("小林","男",13,"123"),
Student("小林","男",14,"124")
};
string strnum;
cout<<"enter number:";
cin>>strnum;
Student *present=find(st,st+4,strnum);
cout<<"这个学生的学号是:"<<present->getNumber()<<endl;
int age;
cout<<"enter age: ";
cin>>age;
Student *pre=find(st,st+4,age);
cout<<"这个学生的年龄是:"<<pre->getAge();
getchar();
getchar();
return 0;
}
数组使用find查询用法的更多相关文章
- JavaScript中常见的数组操作函数及用法
JavaScript中常见的数组操作函数及用法 昨天写了个帖子,汇总了下常见的JavaScript中的字符串操作函数及用法.今天正好有时间,也去把JavaScript中常见的数组操作函数及用法总结一下 ...
- 【shell】构造并遍历二位数组的一种用法
参考shell数组的部分操作用法,实现了构造和遍历二维数组的一种方式,具体如下: #数组元素以空格分割 sites=("www.a.com www.b.com www.c.com www.d ...
- JS中Array数组的三大属性用法
原文:JS中Array数组的三大属性用法 Array数组主要有3大属性,它们分别是length属性.prototype属性和constructor属性. JS操作Array数组的方法及属性 本文总结了 ...
- Ruby数组(1):基本用法
数组 Ruby中的数组是一个容器,数组中的每个元素都是一个对象的引用. 注意,Array类中包含了Enumerable模块,所以Enumerable中的方法也都能使用,例如Enumerable中的re ...
- Hibernate中Restrictions查询用法(转)
Restrictions查询用法 HQL运算符 QBC运算符 含义 = Restrictions.eq() 等于equal <> Restrictions.ne() 不等于not equa ...
- mysql union 和 left join 结合查询用法
union 和 left join 结合查询用法 SELECT u.nickname,z.group_comming_type,z.id,z.user_id,z.title,z.create_time ...
- hashSet的底层是数组,其查询效率非常高
如果偷懒,没有设定equals(),就会造成返回hashCode虽然结果相同,但在程序执行的过程中会多次地调用equals(),从而影响程序执行的效率. 我们要保证相同对象的返回的hashCode一定 ...
- Java-MyBatis-杂项:MyBatis根据数组、集合查询
ylbtech-Java-MyBatis-杂项:MyBatis根据数组.集合查询 1.返回顶部 1. foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合.foreach元素的 ...
- mysql子查询用法
mysql子查询用法 1 可以当值来用<pre>select id from hcyuyin_share where id=(select id from hcyuyin_share li ...
随机推荐
- 在 App 扩展和主 App 间共享数据
tags: iOS 8,Swift,App Groups 随着 iOS 8 的发布,苹果为广大开发者很多新的 API,其中最突出显著的就非 App Extension 莫属了.这为开发者们又带来了很多 ...
- ExtJS4.x 开发环境搭建
需要的资源 ExtJS4.2 eclipse 开发环境搭建 在项目中国需要引用的文件: eclipse中有报错.需要处理的是ext-lang-zh_CN.js,中文编码不能识别.右键->属性-& ...
- winform 表单正则表达式验证 示例(ValidationRule)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- .net mvc通过ucenter和 discuz的整合,nopcommerce ucenter 插件的方式实现
discuz无疑是目前市面上最好的论坛之一,对于大多数公司来说,用discuz搭建一个论坛肯定是最节约成本的选择,然而我们的会员想要和discuz进行整合的话,只有两种荀泽,一种直接选用discuz的 ...
- 二、verilogHDL行为描述建模
1.综合器: 能把行为级的verilog模块自动转换为门级结构的工具叫做综合器(synthsis tool) 2.verilog网表(verilog netlist): 电路结构可以用门级verilo ...
- MyEclipse导入jquery等文件报错的解决方案
1.选中报错的jquery文件例如“jquery-1.8.0.min.js”. 2.右键选择 MyEclipse-->Exclude From Validation . 3.再右键选择 MyEc ...
- Careercup - Google面试题 - 5661939564806144
2014-05-06 01:40 题目链接 原题: Give a N*N matrix, print it out diagonally. Follow up, if it is a M*N matr ...
- android webview开启html5支持
最近做的一个小项目需要用到webview.虽然只是一个简单的网页,但是由于以前用的都只是显示本地文件,没有显示网页文件.现在需要显示网页文件,发现许多网站的webapp做的挺不错的,无论是显示还是用户 ...
- ACK
ACK (Acknowledgement),即确认字符,在数据通信中,接收站发给发送站的一种传输类控制字符.表示发来的数据已确认接收无误. 目录 1基本介绍 2详细释义 1基本介绍编辑 英文缩 ...
- 【转载】Android异步处理系列文章
本博文地址:http://blog.csdn.net/mylzc/article/details/6777767 转载请注明出处. 为了给用户带来良好的交互体验,在Android应用的开发过程中需要把 ...