用 #include <filename.h> 格式来引用标准库的头文件
标准 格式 gt 引用 lt include 头文件 filename
2023-09-14 09:12:04 时间
用 #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 }
相关文章
- php 把数组保存为标准的数组格式,存储到文件中
- 以太网帧、IP数据包格式标准
- 【收藏】OGC标准服务 WMS WCS WFS WPS
- 浏览器标准模式和怪异模式之间的区别是什么?
- CRM WebClient UI里标准configuration和custom configuration区别
- atitit.attilax的软件 架构 理念.docx 1. Atitit 软件设计的模型 frm lib standard 框架类库标准 FLS模型 2. fusco 3. Cirx
- Atitit webservice发现机制 WS-Discovery标准的规范attilax总结
- Atitit.常见软件 数据 交换格式 标准
- Atitit.5gl 第五代语言编程语言 PROLOG教程 人工智能语言的标准 与实现
- atitit.标准时间格式 互相转换 秒数 最佳实践
- 200+Python超全标准库,全掌握了你就是大神~建议收藏留用
- 复习C++标准库多线程的基本使用
- 空间转录组从loupe软件自动聚类之后,分为11个群,使用seurat中的doheatmap函数画出top20基因表达热图 此处使用标准流程来进行标准化 normalization
- Python标准库:内置函数classmethod(function)
- Python标准库:内置函数compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1)
- Python标准库:内置函数len(s)
- Python标准库:内置函数repr(object)
- ERC721标准与加密猫
- 大话中国C-V2X通讯标准应用层标准
- 系统编程(九)文件IO标准库API getc putc