前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
/*★ Algorithm Step1 前田 稔 ★*/
#include <iostream>
#include <vector>
using namespace std;
void main()
{
int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
// int a[] を表示
cout << "a[] ";
disp(a, a+10);
}
|
template<class InputIterator>
void
disp(InputIterator first, InputIterator last)
{
while(first != last)
{
//★cellのデータを印字して下さい。
++first;
}
cout << endl;
}
|
![]()
int t[] = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
vector<int> v(t, t+10);
// vector v を表示
cout << "vector v ";
disp(v.begin(), v.end());
|
int t[] = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
list<int> lst(t,t+10);
// list lst[] を表示
cout << "list lst ";
disp(lst.begin(), lst.end());
|
![]()