Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
只要满足条件,我想计算一次元素 v[i] 。
在开始循环之前创建一个计数器变量,并在条件满足后对其进行递增:
int count = 0; for(int i = 0; i < m; i++){ if((v[i] - p) < 3 ){ count++; p = i; } }