解题思路:
注意事项:
参考代码:
#include <iostream> #include <cmath> using namespace std; int main() { int n; int flag, f1 = 0, f2 = 0; cin >> n >> flag; while(--n) { int tmp; cin >> tmp; if(abs(tmp) < abs(flag) && tmp > 0) f1++; if(abs(tmp) > abs(flag) && tmp < 0) f2++; } if(f1 == 0 && flag < 0 || f2 == 0 && flag > 0) cout << 1 << endl; else cout << f1 + f2 + 1 << endl; return 0; }
0.0分
2 人评分