-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment1.cpp
More file actions
51 lines (44 loc) · 1011 Bytes
/
Copy pathAssignment1.cpp
File metadata and controls
51 lines (44 loc) · 1011 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<bits/stdc++.h>
using namespace std;
int main()
{
ifstream f("input.c");
ofstream f2("output.txt");
if(!f.is_open()){
cout << "File can not be opened\n";
return 0;
}
string l;
int ok = 0;
while(getline(f,l))
{
size_t flag1 = l.find("/*");
size_t flag2 = l.find("*/");
if(flag1 != string::npos) ok = 1;
if(flag2 != string::npos) {
ok = 0;
continue;
}
if(ok) continue;
size_t start = l.find("//");
if(start != string::npos)
{
string l2 = l.substr(0, start);
f2 << l2;
}
else{
int flag = 0;
for(char c : l)
{
if(c != ' ' && flag == 0)
{
flag = 1;
}
if(flag) f2 << c;
}
}
}
f.close();
f2.close();
return 0;
}