Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a[9] = {2, 2, 3, 4, 3, 7, 10, 9, 1};
- int b[10] = {1, 0, 0, 0, 1, 1, 0, 0, 0, 0};
- int s = 10, n_a = 9, n_b = 10;
- int NrSecv(int a[], int n, int s)
- {
- int nr_s = 0;
- for(int i = 0; i < n; i++)
- {
- int nr = a[i];
- for(int j = i+1; nr < s; j++)
- nr += a[j];
- if(nr == s) nr_s++;
- }
- return nr_s;
- }
- int Secv0(int a[], int n)
- {
- int nr0 = 0, nr0max = 0;
- for(int i = 0; i < n; i++)
- {
- if(a[i] == 1) nr0 = 0;
- else nr0++;
- if(nr0 > nr0max) nr0max = nr0;
- }
- return nr0max;
- }
- void SecvDiv(int a[], int n, int &s, int &d)
- {
- int sum;
- for(s = 0; s < n; s++)
- {
- sum = 0;
- for(d = s; d < n; d++)
- {
- sum += a[d];
- if(sum % n == 0) return;
- }
- }
- }
- int main()
- {
- cout << NrSecv(a, n_a, s) << "\n";
- cout << Secv0(b, n_b) << "\n";
- int s = 0, d = 0;
- SecvDiv(a, n_a, s, d);
- cout << s << " " << d;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement