c++ primer plus 第七章-编程题7.13.6《Fill_array,Show_array,Reverse_array》
来源:互联网 发布:淘宝网唯品会 编辑:程序博客网 时间:2024/06/05 10:23
/* Enter a double number: 1 2 3 4 5 q Input 5 number to d[dSzie]. all d[0] ~ d[10]: 1 2 3 4 5 all d[0] ~ d[10]: 5 4 3 2 1 */#include <iostream>#include <array>#include <vector>using namespace std;const int dSize =10;int Fill_array(array<double, dSize> *);void Show_array(array<double, dSize> *,int);void Reverse_array(array<double, dSize> *,int);int main() { array<double, dSize> d; int count = Fill_array(&d); cout << "Input " << count << " number to d[dSzie]." << endl; Show_array(&d, count); Reverse_array(&d, count); Show_array(&d, count);}int Fill_array(array<double, dSize> * pd) { int i = 0, count =0; cout << "Enter a double number: "; while (i < dSize){ if (cin >> (*pd)[i]) { count++; i++; } else break; } return count;}void Show_array(array<double, dSize> * pd,int count) { int i = 0; cout << "all d[" << i << "]" << " ~ d[" << dSize << "]:\n"; while (i < count) { cout << (*pd)[i++] << " "; } cout << "\n";}void Reverse_array(array<double, dSize> * pd,int count) { int end = count - 1, start = 0; double tmp; while (start != end) { tmp = (*pd)[start]; (*pd)[start] = (*pd)[end]; (*pd)[end] = tmp; start++; end--; }}
0 0
- c++ primer plus 第七章-编程题7.13.6《Fill_array,Show_array,Reverse_array》
- 《C Plus Primer》第七章编程题
- C Primer Plus 第七章 编程练习 1-6题
- C Primer Plus 第七章 编程练习 7-11题
- c++ primer plus 第七章《编程题7.13.9》
- c++ primer plus 第七章《编程题7.13.7》
- c++ primer plus 第七章《编程题7.13.8a》
- c++ primer plus 第七章《编程题7.13.8b》
- c++ primer plus 第七章《编程题7.13.10》
- c primer plus 第七章
- c primer plus 第七章
- c primer plus 第七章
- c primer plus 第七章
- 《c primer plus》编程练习回顾-第七章
- C primer plus(第五版)编程练习第七章
- c++.primer.plus第五版第七章编程练习答案
- C.Primer.Plus(第六版)第七章 编程练习
- C ++ Primer Plus 第六版 第七章编程练习答案
- 程序员必须掌握的十种算法---二分查找算法
- iOS开发 -- 耦合 ,target/action设计模式
- linux查看目录占用空间
- 1053. Path of Equal Weight (30)
- C#中的JSON封装与解析
- c++ primer plus 第七章-编程题7.13.6《Fill_array,Show_array,Reverse_array》
- gitlab操作命令
- sshd源码下载与编译安装
- BMP位图信息·DIB结构
- git 代码协同之回车问题
- hdu(5402)——Travelling Salesman Problem(模拟题)
- common.io中Tailer类读取文件内容乱码问题解决
- Android基础入门教程——2.3.8 SeekBar(拖动条)
- Spring Cache 使用