Deq1 cpp Defines the entry point for the console application include s

 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Deq1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
using namespace std;
// Приписать слева к исходному деку элементы другого дека, выбирая их слева
int _tmain(int argc, _TCHAR* argv[])
{
Deq a,b;
int t,t1;
FILE* f1 = fopen("input.txt", "r");
if (f1 == NULL)
{
cout<<"error at opening";
system("pause>nul");
return -1;
}
cout<<"Deq1: ";
fscanf(f1, "%d", &t);
for (int i=0; i<t; ++i)
{
fscanf(f1, "%d", &t1);
a.Push_right(t1);
cout<<t1<<" ";
}
cout<<endl<<"Deq2: ";
fscanf(f1, "%d", &t);
for (int i=0; i<t; ++i)
{
fscanf(f1, "%d", &t1);
b.Push_right(t1);
cout<<t1<<" ";
}
fclose(f1);
while (b.Pop_left(&t))
{
a.Push_left(t);
}
cout<<endl<<"Result: ";
while (a.Pop_left(&t))
{
cout<<t<<" ";
}
system("pause>nul");
return 0;
}