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

用类似与这种算法的同学注意初始化!!!!

Posted by pdjl17 at 2011-05-02 10:51:28 on Problem 1552
#include<iostream>
using namespace std;
int main()
{
	int i,cx=0;
	bool a[100];
	while(cin>>i)
	{	memset(a,0,sizeof(a));//要在这里初始化a数组
		if(i==-1)break;

		a[i]=true;
		while(cin>>i)
		{
			if(i==0) break;
			a[i]=true;			
		}
		cx=0;
		for(i=1;i<50;i++)
			if(a[i]==true&&a[i*2]==true)
				cx++;
		cout<<cx<<endl;		
	}
	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