gpt4 book ai didi

c - 如何自动化可变输入数组列表

转载 作者:太空宇宙 更新时间:2023-11-04 06:47:25 25 4
gpt4 key购买 nike

我需要调用一系列需要输入数组中的列表的函数,如下所示:

1st call to func:
custom_type_t inarray = {1,2,3,4,5,6,7,8,9,10};
2nd call to func:
custom_type_t inarray = {11,12,13,14,15,16,17,18,19,20};
...

我如何将它打包到一个函数中,我可以用一个特定的参数调用它,它会提取数字并相应地填充数组?我应该相应地使用预编译器吗?感谢您的任何想法!

最佳答案

for(int i = 1; i < 11; i++) inarray[i - 1] = i;

for(int i = 11; i < 21; i++) inarray[i - 11] = i;

关于c - 如何自动化可变输入数组列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56194106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com