Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Continuous Sub Set with given sum
//Title of this code #include <iostream> #include <vector> using namespace std; void continuousSubSet(vector<int>& t, int sumToFind) { for (int i = 0; i < t.size(); ++i) { int sum = 0; for (int j = i; j < t.size(); ++j) { sum += t[j]; if (sum == sumToFind) cout << i << " - " << j << endl; } } } int main() { vector<int> t; t.push_back(1); t.push_back(1); t.push_back(2); t.push_back(1); t.push_back(3); t.push_back(5); t.push_back(-1); t.push_back(5); continuousSubSet(t, 4); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
DeltaX campus recruitment
Q
Lockable static queue
weird cast in qt moc files
¡Arriba, Papalotes, Arriba! v2
Изволов#2
iuadhfaoiufs
TwoANOVA
Test 01 c++
hey
stackse - search stackoverflow differently
Please log in to post a comment.