algorithm 简单用法

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std; int student_Score[] = { 50,80,93,23,66}; void pritit(int nScore)
{
cout<<nScore<<" ";
}
bool unPass(int nScore)
{
return nScore < 60;
}
bool Pass(int nScore)
{
return nScore >= 60;
} int main(int argc, char* argv[])
{
vector<int> v_score(student_Score,student_Score+sizeof(student_Score)/sizeof(int));
vector<int>::iterator index; sort(v_score.begin(),v_score.end()); //排序 for_each(v_score.begin(),v_score.end(),pritit); cout<<endl; //显示 index = min_element(v_score.begin(),v_score.end()); //显示最小
cout<<"最小分数 "<<*index<<endl; index = max_element(v_score.begin(),v_score.end()); //显示最大
cout<<"最大分数 "<<*index<<endl; cout<<"低于60的数量 " <<count_if(v_score.begin(),v_score.end(),unPass)<<endl; //显示低于60分的数量 cout<<"高于60的数量 "<<count_if(v_score.begin(),v_score.end(),Pass)<<endl; //高于60的数量 int sum = 0;
for (index = v_score.begin(); index != v_score.end(); index++) //平均数
{
sum += *index;
}
cout<<"平均数 "<<sum / v_score.size() <<endl; return 0;
}

algorithm 简单用法的更多相关文章

  1. CATransition(os开发之画面切换) 的简单用法

    CATransition 的简单用法 //引进CATransition 时要添加包“QuartzCore.framework”,然后引进“#import <QuartzCore/QuartzCo ...

  2. jquery.validate.js 表单验证简单用法

    引入jquery.validate.js插件以及Jquery,在最后加上这个插件的方法名来引用.$('form').validate(); <!DOCTYPE html PUBLIC " ...

  3. NSCharacterSet 简单用法

    NSCharacterSet 简单用法 NSCharacterSet其实是许多字符或者数字或者符号的组合,在网络处理的时候会用到 NSMutableCharacterSet *base = [NSMu ...

  4. [转]Valgrind简单用法

    [转]Valgrind简单用法 http://www.cnblogs.com/sunyubo/archive/2010/05/05/2282170.html Valgrind的主要作者Julian S ...

  5. Oracle的substr函数简单用法

    substr(字符串,截取开始位置,截取长度) //返回截取的字 substr('Hello World',0,1) //返回结果为 'H'  *从字符串第一个字符开始截取长度为1的字符串 subst ...

  6. Ext.Net学习笔记19:Ext.Net FormPanel 简单用法

    Ext.Net学习笔记19:Ext.Net FormPanel 简单用法 FormPanel是一个常用的控件,Ext.Net中的FormPanel控件同样具有非常丰富的功能,在接下来的笔记中我们将一起 ...

  7. TransactionScope简单用法

    记录TransactionScope简单用法,示例如下: void Test() { using (TransactionScope scope = new TransactionScope()) { ...

  8. WPF之Treeview控件简单用法

    TreeView:表示显示在树结构中分层数据具有项目可展开和折叠的控件 TreeView 的内容是可以包含丰富内容的 TreeViewItem 控件,如 Button 和 Image 控件.TreeV ...

  9. listActivity和ExpandableListActivity的简单用法

    http://www.cnblogs.com/limingblogs/archive/2011/10/09/2204866.html 今天自己简单的总结了listActivity和Expandable ...

随机推荐

  1. KSTORE日常工作遇到问题总结

    1.csv导入kstore命令语句 oimpexp -F "E:/127.csv" -S KSTORE -T "T_BUSDATA"  -d 1 -z -B 7 ...

  2. grep -rl tttt /data/ 命令在 /data 目录下面搜寻包含tttt字符的命令

    grep --help -R, -r, --recursive equivalent to --directories=recurse -l, --files-with-matches print o ...

  3. HTTP响应头缓存控制

    在一般Web开发中,有时需要设置特殊的HTTP响应头阻止客户端(一般是浏览器)缓存(使用)该次请求的响应. 这时候大部分开发人员都是百度或谷歌几段代码复制粘贴即了事. 以下简述一下关于缓存控制的几种H ...

  4. 【windows7 + Appium】之Appium安装以及其他工具安装配置

    首先感谢虫师总结的教程:<appium新手入门>.以及:<appium新手入门(2)—— 安装 Android SDK> 目录: 安装Appium&安装node.js ...

  5. UVa 10651 Pebble Solitaire(DP 记忆化搜索)

    Pebble Solitaire Pebble solitaire is an interesting game. This is a game where you are given a board ...

  6. git使用命令行方式提交代码到github或gitlab上

    (1)使用命令行(Git Bash)在gitlab上新建项目的流程   //进入项目目录下: C:\Users\wuwy>cd D:\workspace\eclipse\H5Patient\// ...

  7. 在ListView的GroupItem头中显示每列的Summary

    问题描述 WPF自带的ListView和DataGrid控,都提供了数据分组的支持,并可以对分组的Header进行自定义.但是,如果想在每个分组的Header中,显示出本分组的"小计&quo ...

  8. 执行cp命令时提示cp: 略过目录

    执行cp命令时提示cp: 略过目录 加入-r之后成功拷贝 在网上search了一下CP命令的用法: CP命令 该命令的功能是将给出的文件或目录拷贝到另一文件或目录中,同MSDOS下的copy命令一样, ...

  9. Delphi Property详解

    http://anony3721.blog.163.com/blog/static/51197420107105132120/?ignoreua Property Keyword Defines co ...

  10. 九度OJ 1345:XXX定律之画X (递归)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:361 解决:157 题目描述: 给你一个n,然后让你输出F(n) 规则是这样的,F(n)的输出结果是: F(n-1)     F(n-1) ...