-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvector.cpp
More file actions
31 lines (27 loc) · 700 Bytes
/
vector.cpp
File metadata and controls
31 lines (27 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <fstream>
#include <vector>
#include <cstdlib>
#define N 5
int main(int argc, char* argv[])
{
// int n = std::atoi(argv[1]);
// std::vector<int> v1(n);
// for (int i = 0; i < n; i++)
// v1[i] = std::atoi(argv[i + 2]);
std::fstream fs;
fs.open(argv[1]);
int n;
fs >> n;
std::vector<int> v1(n);
for (int i = 0; i < n; i++)
fs >> v1[i];
std::cout << "v = [";
std::vector<int>::iterator v1_iterator = v1.begin();
std::vector<int>::iterator v1_end = v1.end();
for (; v1_iterator != v1_end; ++v1_iterator)
std::cout << *v1_iterator << " ";
std::cout << "\b]" << std::endl;
fs.close();
return 0;
};