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 DHM1 at 2009-08-19 17:15:54 on Problem 1552
#include<iostream>
using namespace std;
int main()
{
int a,b,array[100],i,j,k,t,sum;
while(cin>>a)
{if(a==-1) break;
k=1;
array[0]=a;
sum=0;
while(cin>>b)
if(b!=0)
{array[k]=b;k++;}
else break;
for(i=0;i<k;i++)
{for(j=0;j<k-i-1;j++)
if(array[j]>array[j+1]) {t=array[j];array[j]=array[j+1];array[j+1]=t;}
}
for(i=0;i<k;i++)
for(j=i+1;j<k;j++)
if(array[j]==2*array[i]) {sum++;continue;}
cout<<sum<<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