-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiles.cpp
More file actions
90 lines (76 loc) · 1.6 KB
/
files.cpp
File metadata and controls
90 lines (76 loc) · 1.6 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <fstream>
using namespace std;
int files_1(){
char filename[255];
cin >> filename;
char filename2[255];
cin >> filename2;
ifstream(fin);
ofstream(fout);
fout.open(filename2);
fin.open(filename);
char c;
bool opened = false;
while(fin.get(c))
{
if (c != '$')
fout << c;
else if(!opened){
opened = true;
fout << "<math>";
fin.get(c);
if (c!='$')
fout << c;
}
else {
opened = false;
fout << "</math>";
fin.get(c);
if (c!='$')
fout << c;
}
}
fin.close();
fout.close();
return 0;
}
int files_2(){
char filename[255];
cin >> filename;
char filename2[255];
cin >> filename2;
ifstream(fin);
ofstream(fout);
fout.open(filename2);
fin.open(filename);
char c;
while(fin.get(c))
{
string sequence;
fout << "00000000: ";
for(int i = 0; i < 16; ++i)
{
fin.get(c);
sequence += c;
}
for(int i = 0;i < 8; ++i)
{
if (sequence[i] < 32)
sequence[i]=' ';
fout << hex << (int) sequence[i] << " ";
}
fout << '|';
for(int i = 8; i < 16; ++i)
{
if (sequence[i]<32)
sequence[i]=' ';
fout << hex << (int) sequence[i] << " ";
}
fout << '|';
fout << sequence << endl;
}
fin.close();
fout.close();
return 0;
}