Advertisement
A1fredPennyworth

Untitled

Jun 3rd, 2023
1,153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. void summator(void *state, const void *element) {
  2.     *(int *)state += *(const int *)element;
  3. }
  4.  
  5. int main() {
  6.     int result = 0;
  7.     int init_val = 0;
  8.     int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  9.     std_accumulate((void *)(&result), a, sizeof(int), 10, &init_val, summator);
  10.     printf("%d\n", result);
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement