-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path#27 Compare Paths of Two Files
248 lines (221 loc) · 5.82 KB
/
#27 Compare Paths of Two Files
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
// C++ Program to Compare Paths of Two Files
// Om Bhikshu Jai Bhikshu
// Jai Jai JyotiCharan Jai Jai Mahashraman
// Rishab Dugar
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define l long
#define ll long long
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define rf(i, a, b) for (ll i = a; i >= b; i--)
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define all(a) a.begin(), a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define endl "\n"
#define ff first
#define ss second
#define PI 3.141592653589793238462
typedef long double lld;
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
/*********************************************************************************/
void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}
template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
/*********************************************************************************/
//const int M=1e9+7;
/*
ll mod(ll x, ll M){
return ((x%M + M)%M);
}
ll add(ll a, ll b, ll M){
return mod(mod(a,M) + mod(b,M) , M);
}
ll mul(ll a, ll b, ll M){
return mod(mod(a,M) * mod(b,M) , M);
}
*/
/*********************************************************************************/
#define cinstr(str) getline(cin >> ws, str)
// Trim trailing and leading white space
const std::string WHITESPACE = " \n\r\t\f\v";
std::string ltrim(const std::string &s)
{
size_t start = s.find_first_not_of(WHITESPACE);
return (start == std::string::npos) ? "" : s.substr(start);
}
std::string rtrim(const std::string &s)
{
size_t end = s.find_last_not_of(WHITESPACE);
return (end == std::string::npos) ? "" : s.substr(0, end + 1);
}
std::string trim(const std::string &s) {
return rtrim(ltrim(s));
}
//int in=stoi(str)
/*********************************************************************************/
ll gcd(ll a, ll b) {
return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
return (a / gcd(a, b)) * b;
}
vector < ll > sieve(int n) {
int * arr = new int[n + 1]();
vector < ll > vect;
for (int i = 2; i <= n; i++)
if (arr[i] == 0) {
vect.push_back(i);
for (int j = 2 * i; j <= n; j += i) arr[j] = 1;
} return vect;
}
vector < bool > sievebool(ll n) {
vector < bool > isPrime(n + 1, true);
for (int i = 2; i * i <= n; i++) {
if (isPrime[i]) {
for (int j = i * i; j <= n; j = j + i) {
isPrime[j] = false;
}
}
}
return isPrime;
}
bool isPowerOfTwo(ll n) {
if (n == 0) {
return false;
}
return (ceil(log2(n)) == floor(log2(n)));
}
void swap(int & a, int & b) {
a ^= b;
b ^= a;
a ^= b;
}
long long bin_exp(long long a, long long n) {
long long res = 1;
while (n > 0) {
if (n & 1) {
res = res * a;
n--;
} else {
a = a * a;
n /= 2;
}
}
return res;
}
long long mod_exp(long long a, long long n, long long mo) {
long long res = 1;
a %= mo;
while (n > 0) {
if (n & 1) {
res = (res * a) % mo;
n--;
} else {
a = (a * a) % mo;
n /= 2;
}
}
return res;
}
ll mod_inv(ll n, ll mo) {
return mod_exp(n, mo - 2, mo);
}
/*********************************************************************************/
// nCr functions :
/*
vector < ll > fact(1000001, 0);
void compute_fact(ll mo) {
fact[0] = fact[1] = 1;
for (ll i = 2; i <= 1000000; i++) {
fact[i] = fact[i - 1] * i % mo;
}
}
ll nCr(ll n, ll r, ll mo) {
if (r > n) return 0;
if (r == 0) return 1;
ll res = fact[n];
res = res * (mod_inv(fact[r], mo)) % mo;
res = res * (mod_inv(fact[n - r], mo)) % mo;
return res;
}
*/
/*********************************************************************************/
void solve()
{
ll n;
cin>>n;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("Error.txt", "w", stderr);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout<<fixed;
cout<<setprecision(10);
ll t=1;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
// function to compare two paths
void pathCompare(string p1, string p2)
{
// stores compared value 0 or >0 or <0
const int res = p1.compare(p2);
if (res > 0)
cout << p1 << " is greater than " << p2;
else if (res == 0)
cout << p1 << " is equal to " << p2;
else
cout << p1 << " is less than " << p2;
cout << "\n";
}
// Driver code
int main()
{
string p1 = "/a/b/c";
string p2 = "/a/b/";
string p3 = "/a/b";
string p4 = "/a/b";
string p5 = "/a/b";
string p6 = "/a/b.";
pathCompare(p1, p2); // function call
pathCompare(p3, p4); // function call
pathCompare(p5, p6); // function call
return 0;
}