Description
1 4 3 2 9 7 18 22
Input
Output
Sample Input
1 4 3 2 9 7 18 22 0 2 4 8 10 0 7 5 11 13 1 3 0 -1
Sample Output
3 2 0
#include<iostream> #include <algorithm> using namespace std; int main() { int a[100],i,n,j,k;; cin>>a[0]; while(a[0]!=-1) { i=1; n=0; while(a[0]&&cin>>a[i]&&a[i]) { i++; } for(j=0;j<=i;j++) for(k=j+1;k<=i;k++) if(2*a[j]==a[k]||a[j]==2*a[k]) {n++;} cout<<n<<endl; cin>>a[0]; } return 0; }
B - Doubles(1.2.1),布布扣,bubuko.com
原文:http://blog.csdn.net/rememberautumn/article/details/37735965