蓝桥 历届试题 蚂蚁感冒

    xiaoxiao2021-03-25  244

    #include <cstdio> #include <algorithm> using namespace std; int main() { int n,p=0,q=0,i,j; int a[55]={0}; scanf ("%d",&n); for (i=0;i<n;i++) scanf ("%d",&a[i]); for (i=1;i<n;i++) { if (a[i]<0 && abs(a[i])>abs(a[0])) p++; if (a[i]>0 && abs(a[i])<abs(a[0])) q++; } if ((a[0]>0 && q==0) || (a[0]<0 && p==0)) printf ("1\n"); else printf ("%d\n",p+q+1); return 0; }
    转载请注明原文地址: https://ju.6miu.com/read-208.html

    最新回复(0)