Question
one-dimension array processing algorithms Find the maximal value use it with the given code below: Replace this template with your solutions (comments are welcome): #include
one-dimension array processing algorithms
Find the maximal value use it with the given code below:
Replace this template with your solutions (comments are welcome):
#include "stdafx.h"
#include
#include
// :::
// For each grade level variant implement own function, e.g.:
int solution_for_grade_6(const int arr[], size_t arr_size)
{
int result = 0;
__asm
{
// Find maximal value code using Inline Assembler instructions go here
// :::
mov [result], eax ; saves the result
}
return result;
}
// :::
int main()
{
int test_result;
// Change the element count and values according to your algorithm needs:
int test_arr1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
test_result = solution_for_grade_6(test_arr1, sizeof(test_arr1)/sizeof(test_arr1[0]));
// You can use assert() function to test for correctness:
assert(expected_result == test_result);
// Or print the results to console:
printf("Grade 6 result1 = %d ", test_result);
// For the same grade level function you might use different input arrays,
// e.g. to test for side cases:
int test_arr2[] = { 0, -1, 2, -3, 4, -5, 6, -7, 8, -9 };
test_result = solution_for_grade_6(test_arr2, sizeof(test_arr2)/sizeof(test_arr2[0]));
assert(another_expected_result == test_result);
// Or print the results to console:
printf("Grade 6 result2 = %d ", test_result);
// :::
getchar(); // Wait for the Enter key
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started