-
Notifications
You must be signed in to change notification settings - Fork 0
/
LightOj - IPChecking.cpp
64 lines (61 loc) · 1.39 KB
/
LightOj - IPChecking.cpp
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
#include<bits/stdc++.h>
using namespace std;
int arr1[4];
int arr2[4];
int test;
char ch;
bool ans;
int cnt;
stack<int> s;
int main()
{
//freopen("_in.txt", "r", stdin);
cin >> test;
while(test--)
{
scanf("%d.%d.%d.%d",
&arr1[0], &arr1[1],
&arr1[2], &arr1[3]);
// printf("%d %d %d %d\n",
// arr1[0], arr1[1],
// arr1[2], arr1[3]);
getchar();
for(int i=0; i<4; i++)
{
arr2[i]=0;
do
{
scanf("%c", &ch);
if(ch == '\n')
break;
if(ch == '0')
arr2[i] = arr2[i] << 1;
else if(ch=='1')
{
//s.push(0);
arr2[i] = arr2[i] << 1;
arr2[i] |= 1;
}
//cout << arr2[i] << endl;
} while(ch=='0' || ch=='1');
//cout << arr2[i] << endl;
//puts("_________");
}
ans = true;
for(int i=0; i<4; i++)
{
if(arr1[i] != arr2[i])
{
//printf("%d != %d\n", arr1[i], arr2[i]);
ans = false;
break;
}
}
printf("Case %d: ", ++cnt);
if(ans)
puts("Yes");
else
puts("No");
}
return 0;
}