zoukankan      html  css  js  c++  java
  • 用 #include <filename.h> 格式来引用标准库的头文件

    用 #include <filename.h> 格式来引用标准库的头文件(编译器将从 标准库目录开始搜索)。

     1 #include <iostream>
     2 
     3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
     4 
     5 
     6 using namespace std;
     7 
     8 //定义结构
     9 struct student {
    10     char  name[10];
    11     float   grade;
    12 };
    13 
    14 //交换student类型的数据 
    15 void swap(student &x,student &y)      //swap的参数为引用传递方式
    16 {
    17     student temp;
    18     temp=x;
    19     x=y;
    20     y=temp;
    21 }
    22 
    23 //返回student类型的引用,求优者 
    24 student& max(student &x,student &y)      //swap的参数为引用传递方式
    25 {
    26     return (x.grade>y.grade?x:y);
    27 }
    28 
    29 //显示student类型的数据 
    30 void show(student &x)      //show的参数为引用传递方式
    31 {
    32    cout<<x.name<<"  "<<x.grade<<endl;
    33 }
    34 int main(int argc, char** argv) {
    35     
    36      student a={"ZhangHua",351.5},b={"WangJun",385};
    37 
    38     //显示a和b的数据
    39     cout<<"a:";
    40     show(a);
    41     cout<<"b:";
    42     show(b);
    43     cout<<"------------------"<<endl;
    44 
    45     //交换a和b的数据,并显示
    46     swap(a,b);    
    47     cout<<"a:";
    48 show(a);
    49     cout<<"b:";
    50 show(b);
    51     cout<<"------------------"<<endl;
    52 
    53     //计算和显示成绩高者
    54     student t=max(a,b);
    55     cout<<"Max:";
    56     show(t);
    57     return 0;
    58 }
  • 相关阅读:
    Mysql update from
    抽象类
    表自链接递归查询死循环
    复制订阅服务器和 AlwaysOn 可用性组 (SQL Server)
    C#找出接口的所有实现类并遍历执行这些类的公共方法
    Cors Http 访问控制
    返回参数去掉xml格式,以纯json格式返回(转)
    混布技术提升资源利用率
    fair scheduler配置
    ambari安装
  • 原文地址:https://www.cnblogs.com/borter/p/9412899.html
Copyright © 2011-2022 走看看