【基礎練習】【vector】codevs3393 序列倒置

來源:互聯網
上載者:User

標籤:vector   類比   

著作權資訊 轉載請註明出處 [ametake著作權]http://blog.csdn.net/ametake歡迎來看

題目很簡單,本質還是練習一下vector

題目描述 Description

給定一個正整數序列,請將這個序列倒置後輸出

輸入描述 Input Description

輸入包括一行,即給定的正整數序列,正整數之間用空格隔開。

輸出描述 Output Description

輸出包括一行,即倒置後的序列。

範例輸入 Sample Input

1 3 5 2 4

範例輸出 Sample Output

4 2 5 3 1

資料範圍及提示 Data Size & Hint

保證序列的長度小於10000,每個數小於32767。

直接push_back進vector 用size測出長度倒序輸出即可

這個本來還是TY君教我的呢 如今TY君不知何處去了 還是有些想念的

我們以為會後繼無人,但是明天早上就會有弟弟妹妹來了 歡迎他們 希望他們也能繼承我們的衣缽好好學 爭取出個進隊爺?【雖然希望渺茫

廢話太多了,上代碼

順帶放上很久之前TY君的字串反轉代碼
#include<iostream>#include<vector>#include<string>using namespace std;main(){    string str;    vector<string>a;//¿ªÒ»¸ö×Ö·û´®µÄÊý×飬Ãû×Ö½Ða     while(cin>>str){//if str exist return 1 else return 0         a.push_back(str);//if it's not the first put it behind the last    }    for(int i=a.size()-1;i>=0;--i)cout<<a[i]<<" ";//output in the opposite way}

——將子無怒,秋以為期

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

【基礎練習】【vector】codevs3393 序列倒置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.