1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-23 15:48:42 +00:00
202401-programming-assignments/【实践课内】9.数组3/7-4 IP地址转换.c

19 lines
294 B
C

#include <stdio.h>
char s[100];
int ip[4];
int main() {
scanf("%s", s);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 8; j++) {
ip[i] = ip[i] * 2 + s[i * 8 + j] - '0';
}
}
printf("%d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
return 0;
}