尋找連續序列,使其和等於n

1,分析: 首尾兩個遊標. 若是當前sum < n, 尾巴向右移動. 若是當前sum > n, 首向右移動. 若是當前sum == n,輸出結果. 首向右移動兩位,尾巴向右移動一位. 循環條件: 首 < (n+1)/2 2,實現代碼: #include <iostream>using namespace std;void FindContinuousSum(int n){ if (n < 3
相關文章
相關標籤/搜索