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

行尾有不等长的垃圾数据。用 while(getchar()!='\n') ; AC。

Posted by swgr at 2008-08-28 00:47:53 on Problem 2105 and last updated at 2008-08-28 00:53:23
#include<stdio.h>

int main()
{
	int n,i,j;
	long d;
	unsigned char *c = &d;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		while(getchar()!='\n') ;
		d=0;
		for(j=31;j>=0;j--)
			if (getchar()=='1') d|=1<<j;
		printf("%d.%d.%d.%d\r\n",c[3],c[2],c[1],c[0]);
	}
	return 0;
}

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