Use array values from a C++ program in blender
You can print your cpp values to the console and execute the app with python's subprocess module. Here is a simple cpp program that outputs random x,y,z values:

#include &lt;iostream&gt;     // std::cout
#include &lt;vector&gt;       // std::vector
#include &lt;ctime&gt;        // std::time
#include &lt;cstdlib&gt;      // std::rand, std::srand

int main () {

  std::vector&lt;float&gt; z(10);
  float x = 0.171; 
  float y = 0.324;

  // iteration to store random numbers
  std::srand (static_cast &lt;unsigned&gt; (std::time(0)));
  for (std::vector&lt;float&gt;::iterator i = z.begin(); i != z.end(); i++){
    *i = static_cast &lt;float&gt; (rand()) / static_cast &lt;float&gt; (RAND_MAX);
  }

  // iteration to print x y z values
  for (std::vector&lt;float&gt;::iterator i = z.begin(); i != z.end(); i++){
    std::cout &lt;&lt; (*i * x) &lt;&lt; " " &lt;&lt; (*i * y) &lt;&lt; " " &lt;&lt; *i &lt;&lt; "\n";
  }

  return 0;
}


The output should be something like this:

0.170636 0.32331 0.997869
0.0806884 0.152883 0.471862
0.0141332 0.0267788 0.0826505
...


Get the values

Use Popen.communicate() to read the output and split the lines as you like:

import subprocess

# path to the app
app = '/home/user/Desktop/app'

# communicate can read the data:
out, err = subprocess.Popen(app, stdout=subprocess.PIPE).communicate() 

#  split the string by line
out = out.splitlines()
print (out)

# create lists
xValues, yValues, zValues = [],[],[]

# append the values to to the lists  
for line in out:
    line = line.strip()
    columns = line.split()
    xValues.append(float(columns[0]))
    yValues.append(float(columns[1]))
    zValues.append(float(columns[2]))

# print the values
print (zValues)


Creating keyframes

Iterate through the z values, set the start frame, offset value (optional)  and use keyframe_insert in order to create keyframes for the selected object(s):

# get selected object
obj = bpy.context.active_object

# animation start frame
start_frame = 1

# frame value
frame_number = start_frame

# keyframe offset
offset = 3

# iterate through z values and apply them
for i in zvalues:
    # set the frame
    bpy.context.scene.frame_set(frame_number)
    # set new location
    obj.location = (0,0,i)
    # insert keyframe
    obj.keyframe_insert(data_path="location", index=-1)
    # add offset value
    frame_number += offset


Adjusting the timeline

To adjust the timeline use bpy.data.actions to get a list of actions in the scene and assign the last key value to bpy.context.scene.frame_end:

# get all actions
action_list = [action.frame_range for action in bpy.data.actions]

# sort, remove doubles and create a set
keys = (sorted(set([item for sublist in action_list for item in sublist])))

# assign new start frame
bpy.context.scene.frame_start = start_frame

# assign new end frame
bpy.context.scene.frame_end = keys[-1]


For more details see this answer: How to find number of animated frames in a scene via python?

Result