Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

比较简洁的参考程序.

Posted by tazerkinq at 2010-11-26 04:47:52 on Problem 2799
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator