#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查询用法的更多相关文章

  1. JavaScript中常见的数组操作函数及用法

    JavaScript中常见的数组操作函数及用法 昨天写了个帖子,汇总了下常见的JavaScript中的字符串操作函数及用法.今天正好有时间,也去把JavaScript中常见的数组操作函数及用法总结一下 ...

  2. 【shell】构造并遍历二位数组的一种用法

    参考shell数组的部分操作用法,实现了构造和遍历二维数组的一种方式,具体如下: #数组元素以空格分割 sites=("www.a.com www.b.com www.c.com www.d ...

  3. JS中Array数组的三大属性用法

    原文:JS中Array数组的三大属性用法 Array数组主要有3大属性,它们分别是length属性.prototype属性和constructor属性. JS操作Array数组的方法及属性 本文总结了 ...

  4. Ruby数组(1):基本用法

    数组 Ruby中的数组是一个容器,数组中的每个元素都是一个对象的引用. 注意,Array类中包含了Enumerable模块,所以Enumerable中的方法也都能使用,例如Enumerable中的re ...

  5. Hibernate中Restrictions查询用法(转)

    Restrictions查询用法 HQL运算符 QBC运算符 含义 = Restrictions.eq() 等于equal <> Restrictions.ne() 不等于not equa ...

  6. mysql union 和 left join 结合查询用法

    union 和 left join 结合查询用法 SELECT u.nickname,z.group_comming_type,z.id,z.user_id,z.title,z.create_time ...

  7. hashSet的底层是数组,其查询效率非常高

    如果偷懒,没有设定equals(),就会造成返回hashCode虽然结果相同,但在程序执行的过程中会多次地调用equals(),从而影响程序执行的效率. 我们要保证相同对象的返回的hashCode一定 ...

  8. Java-MyBatis-杂项:MyBatis根据数组、集合查询

    ylbtech-Java-MyBatis-杂项:MyBatis根据数组.集合查询 1.返回顶部 1. foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合.foreach元素的 ...

  9. mysql子查询用法

    mysql子查询用法 1 可以当值来用<pre>select id from hcyuyin_share where id=(select id from hcyuyin_share li ...

随机推荐

  1. 【译】理解与分析ios应用的崩溃报告

    源网址: http://developer.apple.com/library/ios/#technotes/tn2151/_index.html 当一个应用程序崩溃时,创建一份“崩溃报告”对于理解崩 ...

  2. 010--VS2013 C++ 平面地图贴图

    先准备好地图的小图片: //全局变量HDC mdc;HBITMAP fullmap;const int rows = 8, cols = 8; //-------------------------- ...

  3. 触发器(trigger)的作用???

    1.触发器,英文名trigger,可以简单的理解为: 就相当于是一个事件的触发装置,当满足了一定的事件触发条件后进行相应的操作 例如当复位set信号到来时,我们就让A<=B,这样一个系统就是一个 ...

  4. Android实现页面跳转、ListView及其事件

    Android实现页面跳转.ListView及其事件 开发工具:Andorid Studio 1.3 运行环境:Android 4.4 KitKat 工程内容 进入主页面后,使用ListView实现特 ...

  5. 自定义 tabBar (默认 tabBar 为可读不可写类型)

    KVC 方法 //由于 tabBar是只读 不能够直接操作,如果要修改  可以使用KVC let mainTabBar = MainTabBar() //KVC 赋值 setValue(mainTab ...

  6. Swing做的非阻塞式仿飞秋聊天程序

    采用Swing 布局 NIO非阻塞式仿飞秋聊天程序, 切换皮肤颜色什么的小功能以后慢慢做 启动主程序. 当用户打开主程序后自动获取局域网段IP可以在 设置 --> IP网段过滤, 拥有 JMF ...

  7. “我爱淘”冲刺阶段Scrum站立会议1

    昨天是我们项目冲刺阶段的第一天,站立会议的内容如下: 1.昨天完成了项目中的第一个界面--“精选”界面:完成了一点Java文件的编写: 2.今天的任务就是完成第一个Activity的编写:将布局文件和 ...

  8. FB接口之 js调用支付窗口

    官方文档: https://developers.facebook.com/docs/reference/dialogs/pay/ <html xmlns="http://www.w3 ...

  9. unity3d中的Viewport

    Camera属性中有个Viewport Rect,如下图: X.Y为(0, 0)代表左下角,(1, 1)代表右上角:W和H分别是Viewport的宽(Width)和高(Height),摄像机的Aspe ...

  10. HDU 5792 World is Exploding 树状数组+枚举

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5792 World is Exploding Time Limit: 2000/1000 MS (Ja ...