| ||||||||||
| 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 | |||||||||
Re:行尾有不等长的垃圾数据。用 while(getchar()!='\n') ; AC。In Reply To:行尾有不等长的垃圾数据。用 while(getchar()!='\n') ; AC。 Posted by:swgr at 2008-08-28 00:47:53 > #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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator