如何添加数组的元素? [英] How to add the elements of an array?
本文介绍了如何添加数组的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个数组
a [3] = {1,3,8}
我希望输出为包含通过添加数字获得的数字的数组来自数组a,以及数组a的元素。即,
b [0] = 1
b [1] = 3
b [2] = 8
b [ 3] = 4 //(1 + 3)
b [4] = 9 //(1 + 8)
b [5] = 11 //(3 + 8 )
b [6] = 12 //(1 + 3 + 8)
我该怎么办?
解决方案
看看这里:
http://www.programmingsimplified.com/c/source-code/c-program-insert-element-in-array [ ^
Suppose I have an array
a[3]={1,3,8}
I want the output to be an array containing the numbers obtained by adding numbers from array a, as well as the elements of array a. i.e.,
b[0]=1
b[1]=3
b[2]=8
b[3]=4 //(1+3)
b[4]=9 //(1+8)
b[5]=11 //(3+8)
b[6]=12 //(1+3+8)
How do I do this?
解决方案
Hi,
Have a look here:
http://www.programmingsimplified.com/c/source-code/c-program-insert-element-in-array[^]
这篇关于如何添加数组的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文