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

大牛来看看Runtime Error!我用VC都通过,哪有问题呀!

Posted by lucanyi at 2008-03-07 21:54:11 on Problem 2105
#include "stdio.h"

int power(int n)
{
	int i,power=1;
	if(n==0)
		return 1;
	else
	{
		for(i=0;i<n;i++)
			power*=2;
		return power;
	}	
}

void main()
{
	freopen("2105 IP Address.txt","r",stdin);
	int t,i,j,n;
	char ip[33];
	scanf("%d",&n);
	int **a;
	a=new int *[n];
	for(i=0;i<4;i++)
		a[i]=new int [4];
	for(t=0;t<n;t++)
	{
		scanf("%s",ip);
		for(i=0;i<4;i++)
		{
			a[t][i]=0;
			for(j=8*i;j<8*i+8;j++)
				a[t][i]+=(ip[j]-'0')*power(7+8*i-j);
		}	
	}
	for(t=0;t<n;t++)
		printf("%d.%d.%d.%d\n",a[t][0],a[t][1],a[t][2],a[t][3]);
}

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