You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
440 B
C
18 lines
440 B
C
#include <stdio.h>
|
|
|
|
int main() {
|
|
unsigned int ip[4];
|
|
unsigned int netmask[4];
|
|
unsigned int broadcast[4] = {0, 0, 0, 0};
|
|
int i;
|
|
|
|
scanf("%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], &ip[3]);
|
|
scanf("%d.%d.%d.%d", &netmask[0], &netmask[1], &netmask[2], &netmask[3]);
|
|
for (i = 0; i < 4; ++i) {
|
|
broadcast[i] = (ip[i] & netmask[i]) | (~netmask[i] & 255);
|
|
}
|
|
for (i = 0; i < 3; ++i)
|
|
printf("%d.", broadcast[i]);
|
|
printf("%d", broadcast[3]);
|
|
}
|