| ||||||||||
| 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 | |||||||||
why wa again and again on 2105? 大大们 help!here is my code and it passes the sample very well:
#include<stdio.h>
#include<stdlib.h>
void trans(char *bits,int *bytes)
{
int i,j;
for(i=0;i<4;i++)
{
bytes[i]=0;
for(j=0;j<8;j++)
bytes[i]+=(bits[i*8+j]&1)<<(7-j);
}
}
int main()
{
char bit[32];
int ip[4];
int n,i,j;
while(scanf("%d",&n)!=EOF){
getchar();
for(i=0;i<n;i++){
for(j=0;j<32;j++)
scanf("%c",&bit[j]);
getchar();
trans(bit,ip);
for(j=0;j<4;j++){
if(j==0)
printf("%d",ip[j]);
else
printf(".%d",ip[j]);
}
printf("\n");
}
}
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator