数组使用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 ...
随机推荐
- ios 中使用SBJson拼接和解析json
1.ios解析json 使用开源json包,项目地址: http://stig.github.com/json-framework/ NSData * responseData = [res ...
- 状压DP
今天稍微看了下状压DP,大概就是这样子的,最主要的就是位运算, i and (1<<k)=0 意味着i状态下没有 k : i and (1<<k)>0 意味着i状态下有 ...
- P1119: [POI2009]SLO
这题预处理稍微动动脑,其实还是个裸的置换群=-=,没什么压力. ; var n,i,j,minx,tem,now,tmin,len:longint; cursum,sum:int64; pos,num ...
- 自动化TOPSQL优化脚本
'自动化优化’只是个噱头,要能自动化世界就安静了.只是行里非得要这么个名字. 最基本的抓取系统topsql,是通过awr,但是这样有诸多弊端和不灵活,比如数量较少.不能直接看执行计 ...
- Leetcode-Construct Binary Tree from inorder and preorder travesal
Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that ...
- Android开发随笔4
昨天: 今天: 编写代码
- 团队项目(NABC分析)
我们团队开发的是<校园导航>软件 (1)N(Need需求) 我们的团队主要考虑到我们学校没有自己的校园导航,有时会给同学及参观人员带来不便,又看到好多学校都有自己的导航,所以就从这个需求方 ...
- unity 协同
void Update () { if(Input .GetKeyDown (KeyCode .W )) { StartCoroutine ("Test"); } } IEnume ...
- sudo su 提示没有配置JDK environment
sudo su 提示没有配置JDK environment 最近工作遇到一问题,我通过SecureCRT远程登录服务器,部署web应用.将变更文件替换后,我需要切换到root用户,重启Tomcat.所 ...
- Java 7 中 NIO.2 的使用——第一节 Path 类的使用
路径隶属于文件系统,实际上它是存储和组织媒体文件的格式,通常在一块或多块硬盘设备上,以便于非常容易地检索.文件系统可以通过 java.nio.file.FileSystems 这个final 类来访 ...