重新开始写编程日记!尽管之前空挡较大,但是现在一定要开始了!不能跳票了!

来源:互联网 发布:郑州seo 编辑:程序博客网 时间:2024/04/30 23:47

上机内容:C++程序的编写和运行

上机目的:掌握C++引用

我的程序:

/*     * Copyright (c) 2011, 烟台大学计算机学院   * All rights reserved.   * 文件名称:引用排列大小.cpp   * 作    者:svitter   * 完成日期:2013 年 1 月 24 日   * 版 本 号:v1.0   * 对任务及求解方法的描述部分:  * 输入描述:输入3个数字  * 问题描述:输入3个数字,使用引用来排列大小。* 程序输出:经过排列后的数* 问题分析:略  * 算法设计:略   */#include<iostream>using namespace std;int main(){int a,b,c;void sort(int &d,int &e, int &f);cout<<"input the 3 number:";cin>>a>>b>>c;cout<<"The first number is:"<<a<<" "<<b<<" "<<c<<" "<<endl;sort(a,b,c);cout<<"The sort number is:"<<a<<" "<<b<<" "<<c<<endl;return 0;}void sort(int &d,int &e, int &f){void max(int &g,int &h);max(d,e);max(e,f);max(d,e);}void max(int &g,int &h){int temp;if(g>h){temp=g;g=h;h=temp;}}

运行结果:

心得体会:

  应该有更为简便的方法,考虑的时候开始想要排序法试试,但是发现不太行。因为不是数组啊。后来用了两个函数,也算勉强完成了吧。

  大爱C++。

知识点总结:

  似乎没啥好总结的。。就是注意不要忘记&符号。

原创粉丝点击