| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
水进一万!惭愧...#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator