Reading floats into an array

后端 未结 6 853
[愿得一人]
[愿得一人] 2021-01-22 00:39

How could I read let\'s say 10 floats and store them in an array without wasting any memory?

6条回答
  •  半阙折子戏
    2021-01-22 01:21

    You'll have to be more specific about the problem.

    Unless you have something else that you need to do with these numbers, then the easiest way to save memory is not to store them in an array to begin with.

    It sounds like what you want is something like.

    sum = 0;
    do
      read current
      sum += current
    while (you haven't yet read 10 numbers);

提交回复
热议问题