blob: 03f5d1c067b6404e29a2e5932bc58d4f282864a6 (
plain)
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
|
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
const string fname = argv[1];
const int a = atoi(argv[2]);
const int b = atoi(argv[3]);
ifstream infile(fname);
if (!infile) {
perror(fname.c_str());
exit(1);
}
int lineno = 1;
string s;
while (infile >> s) {
if (a <= lineno && lineno <= b)
cout << s << endl;
lineno++;
if (lineno > b)
break;
}
}
|