#include <stdio.h> #include <stdlib.h> int main() { int numList[15],th=0,i,j; while(scanf("%d",&numList[th++])!=EOF){ int count=0; if(numList[0]==-1) break; while(scanf("%d",&numList[th])!=EOF) { if(numList[th]==0) break; ++th; } for(i=0;i<th-1;i++) { for(j=i+1;j<=th-1;j++) { if((float)numList[i]/numList[j]==0.5 || (float)numList[i]/numList[j]==2.0) count++; } } printf("%d\n",count); th=0; } return 0; }
另外附一个可读性更高的
http://www.cnblogs.com/rainydays/archive/2013/04/03/2998275.html
时间: 2024-11-06 12:04:43