1. 程式人生 > >DS1 4 poj 1552 Doubles 測試組數和每組測試用例的個數不定

DS1 4 poj 1552 Doubles 測試組數和每組測試用例的個數不定

               
#include <iostream>#include <cstdio>using namespace std;const int maxn  = 20;int main()int a[maxn]; cin >> a[0]; while(a[0] != - 1){  int i = 1,j,count = 0;  for(; ; i++){   scanf("%d",&a[i]);   if(a[i] == 0){    break;   }  }  int n = i;  for(i = 0 ; i < n - 1 ; ++i){   for(j = i + 1
; j < n ;++j ){    if(a[i]*2 == a[j] || a[j]*2 == a[i]){     count++;    }   }  }  printf("%d\n",count);  cin >> a[0]; }  return 0; }
Doubles