版权信息 转载请注明出处 [ametake版权全部]http://blog.csdn.net/ametake欢迎来看
题目非常easy,本质还是练习一下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。
这个本来还是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 }
——将子无怒,秋以为期