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 |
比较简洁的参考程序.unsigned n,i,j,tp,mask=~0,ip=~0;//最后三个依次为临时ip,掩码,ip,初始为{1} int main(){ for(scanf("%u ",&n);n--;){ tp=0; for(i=4;i--;){ scanf("%u%*c",&j); tp|=j<<8*i; } ip&=tp; //更新ip for(i=ip^tp;i;i>>=1)mask&=~i;//更新掩码 } ip&=mask; //修正ip for(j=2;j--;) for(i=4;i--;) printf("%d%c",((j?ip:mask)>>8*i)&255,i?'.':'\n'); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator