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

Re:纪念100题,pku的pow函数第一个参数必须为double或者float型,不能为int,又粗心贡献了一次WA,汗~

Posted by 07151104107s at 2009-04-22 21:46:04 on Problem 2105
In Reply To:纪念100题,pku的pow函数第一个参数必须为double或者float型,不能为int,又粗心贡献了一次WA,汗~ Posted by:zxzhangxin at 2009-04-21 20:44:03
> #include<stdio.h>
> #include<math.h>
> #include<memory.h>
> int main()
> {
> 	int n;
> 	char str[50];
> 	int a[4];
> 	int i,j,k,temp;
> 	scanf("%d",&n);
> 	getchar();
> 	while(n--){
> 		gets(str);
> 		memset(a,0,sizeof(a));
> 		j = 0;
> 		for(i=0;i<32;i++){
> 			temp = str[i] - '0';
> 			k = 7 - i%8;
> 			a[j] += temp * (int)pow(2.0,k);
> 			if(i%8==7)
> 				j++;
> 		}
> 		printf("%d.%d.%d.%d\n",a[0],a[1],a[2],a[3]);
> 	}
> 	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