平行阵列和结构?C
parallel arrays and structs? C++
好吧,这是我试图放入一个结构的变量,我有点担心如何使用该结构实现并行数组。结构" StudentType"正确吗?
const int NUM_STUDENTS = 10; //global variables
const int NUM_SCORES = 5;
string studentNames[NUM_STUDENTS], letterGrades[NUM_STUDENTS]; //old program variables
float studentAverages[NUM_STUDENTS];
int studentScores[NUM_STUDENTS][NUM_SCORES];
struct studentType{
string name;
string grade;
float average;
int scores[NUM_SCORES];
};
studentType student[NUM_STUDENTS];
我感谢所有的帮助!
- 您将结构宣布为全局。所以你不需要通过总是。只需保持数组的长度
- 您最好使用类。
我已修复了汇编错误。(不是逻辑错误)
http://pastebin.com/zwdtxthz
相关文章:
- 如何将来自文本文件的数据读取到结构的int阵列中
- 将数据从阵列火阵列传输到犰狳结构
- 将阵列的元素变为结构
- c/c qsort在结构内的结构阵列
- 生态2D结构阵列C
- 如何计算结构阵列内的平均值
- 工会结构阵列的初始化太多
- 如何在C 中创建动态分配的2D结构阵列
- 动态分配的结构阵列具有动态分配的结构阵列元素
- 传递和更新结构阵列
- C 98如何在标题中初始化静态结构阵列
- C 结构阵列带指针
- 用null C 初始化结构阵列
- 结构阵列奇数/偶数故障
- 排序二维结构阵列
- 如何确定另一个结构内的结构阵列的长度
- 结构阵列的初始化列表的行为
- 在结构阵列(AoS)和阵列结构(SoA)之间来回切换
- 2D结构阵列
- 用于将结构阵列(AoS)转换为阵列结构(SoA)的干净代码