| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
后来的请注意EOF!附代码#include "stdio.h"
#include "math.h"
int num[33], add[5];
int ten(int a, int b);
int main() {
int n, i;
char temp;
scanf("%d", &n);
while (1) {
temp = getchar();
if (temp == '\n')
break;
}
while (n--) {
i = 0;
while (1) {
temp = getchar();
if (i < 32 && (temp == '1' || temp == '0')) {
i++;
num[i] = temp - '0';
}
else if (temp == '\n')//这样就错了,加上 || temp == EOF就对了!晕死
break;
}
for (i = 1; i <= 4; i++) {
add[i] = ten(8 * (i - 1) + 1, 8 * i);
}
printf("%d.%d.%d.%d\n", add[1], add[2], add[3], add[4]);
}
return 0;
}
int ten(int a, int b) {
int i, ip = 0;
for (i = a; i < b; i++) {
ip += num[i] * pow(2, 8 - i % 8);
}
ip += num[b];
return ip;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator