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

好好看看C的书吧……

Posted by 00448264 at 2006-01-06 21:58:18
In Reply To: Problem 2105 Posted by:cjp_pku at 2006-01-06 20:59:29
#include<iostream.h>

int main()
{
	int N,j,k,l;
	char ip[32];
	int ip2[32];
	int ans[9][4]={{0},{0},{0},{0}};
	int a[8]={128,64,32,16,8,4,2,1};
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>ip;
		for(j=0;j<32;j++)
		{
			if(ip[j]=='0')
				ip2[j]=0;
			else
				ip2[j]=1;
		}
		l=0;
		for(j=0;j<4;j++)
		{
			for(k=0;k<8;k++)
			{
				ans[i][j]=ans[i][j]+ip2[l]*a[l%8];
				l++;
			}
		}
	}
	for(i=0;i<N;i++)
	{
		cout<<ans[i][0]<<"."<<ans[i][1]<<"."<<ans[i][2]<<"."<<ans[i][3]<<endl;
	}
	return 1;
}

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