fork download
  1. #include <vector>
  2. using namespace std;
  3.  
  4. // Function to count subarrays having sum less than k
  5. int countsubarray(vector<int> &arr, int k)
  6. {
  7. int n = arr.size();
  8. int count = 0;
  9.  
  10. // Pick starting point
  11. for (int i = 0; i < n; i++)
  12. {
  13. int sum = 0;
  14.  
  15. // Pick ending point
  16. for (int j = i; j < n; j++)
  17. {
  18. // If sum is less than k, update sum and count
  19. if (sum + arr[j] < k)
  20. {
  21. sum += arr[j];
  22. count++;
  23. }
  24. else
  25. {
  26. break;
  27. }
  28. }
  29. }
  30.  
  31. return count;
  32. }
  33.  
  34.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty