日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

c++ 将输入存储到数组,然后反转数组,最后输出

發布時間:2025/4/16 c/c++ 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c++ 将输入存储到数组,然后反转数组,最后输出 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
// 輸入一個包含多個double元素的數組,先打印結果,然后反轉出頭和尾元素之外的所有元素,最后再打印結果 #include <iostream> using namespace std; int fill_array(double arr[], int size); void show_array(double arr[], int size); void reverse_array(double arr[], int size);int main() {int size;int inputCount;cout << "Input size: ";cin >> size;double * arr = new double[size];inputCount = fill_array(arr, size);cout << "Entered count: " << inputCount << endl;cout << "Your input: ";show_array(arr, size);cout << "Reverse array (without first and last element)..." << endl;double first = arr[0];double last = arr[size - 1];reverse_array(arr, size);arr[0] = first;arr[size - 1] = last;cout << "The final: ";show_array(arr, size);delete[] arr;return 0; }int fill_array(double arr[], int size) {int count = 0;for (int i = 0; i < size && cin >> arr[i]; i++) {count++;}return count; }void show_array(double arr[], int size) {for (int i = 0; i < size; i++) {cout << arr[i];}cout << endl; }void reverse_array(double arr[], int size) {double temp;int iterCount = size/2;--size;for (int i = 0; i < iterCount; i++, size--) {temp = arr[i];arr[i] = arr[size];arr[size] = temp;} }

  

轉載于:https://www.cnblogs.com/ranwuer/p/9721366.html

總結

以上是生活随笔為你收集整理的c++ 将输入存储到数组,然后反转数组,最后输出的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。