初始化:
#include <deque>
deque<float> fdeque;
算法:
fdeque.push_front(f);
fdeque.push_back(f);
fdeque.size()
代码:
1 #include <deque> 2 #include <iostream> 3 using namespace std; 4 int main() 5 { 6 deque<float> fdeque; 7 8 for(float f = 1.1; f < 9.9; f += 1.1){ 9 fdeque.push_front(f); 10 fdeque.push_back(f); 11 } 12 13 for(int i = 0; i <= (fdeque.size() - 1); i++) 14 cout << fdeque[i] << " | "; 15 16 return 0; 17 }
输出:
$ ./a.exe 8.8 7.7 6.6 5.5 4.4 3.3 2.2 1.1 1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8