fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int f(int*,int*,int);
  6.  
  7. int main()
  8. {
  9. int str1[] = {2, 4, 8, 2};
  10. int str2[] = {7, 3, 5, 2};
  11.  
  12. cout << f(str1,str2,4);
  13.  
  14.  
  15. }
  16.  
  17. int f(int* a, int* b, int size)
  18. {
  19. int ret = 0;
  20. int maxFound = *a+*b;
  21. for(int i = 1; i < size; ++i){
  22. int cur = a[i]+b[i];
  23. if(cur > maxFound){
  24. maxFound = cur;
  25. ret = i;
  26. }
  27. }
  28. return ret;
  29. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
2