构造并行阵列的问题。 [英] Contstructing Parallel Arrays question.

查看:78
本文介绍了构造并行阵列的问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建两个一维并行数组,这将为我输入的任何分数提供一个字母等级。我需要的两个阵列是最低分和等级。我不明白如何构建得分数组。得分如下:0 - 299应该得到一个F

300 - 349应该导致一个D

350 - 399会导致一个C

400 - 449应该会产生一个B

450 - 500会导致A


我不知道如何输入分数数据一系列的数据。


非常感谢任何类型的帮助/指针。

解决方案

你需要一个用于评分最高分数的数组和一个用于评分最低分数的数组,加上字母等级数组给出3个数组。


但是我不会这样做,最低分数,最高分和字母等级都与其他相关。我会创建一个包含最小分数,最高分和字母等级的结构,然后有一系列结构

展开 | 选择 | 换行 | 行号


< blockquote>


你需要一个数组来获得成绩的最高分数和一个最低分数的数组,加上字母等级数组给出3个数组。


但是我不会这样做,最低分,最高分和字母等级都与ech其他相关。我会创建一个包含最小分数,最高分和字母等级的结构,然后有一系列结构

展开 | 选择 | 换行 | 行号


< blockquote>只存储最小值或最大值,查看您的数据


得分[5] = {0-299,300-349,350-399,400-449,450 -500};


在所有情况下最大限制为1指数=下一个指数的最低限制 - 1




299 = 300 - 1

349 = 350 - 1

399 = 400 - 1

449 = 450 - 1

通过尝试存储每个等级的最大值和最小值,您正在复制数据。


您可以存储最大值(或最小值是您的选择)对于每个年级,并从该数据构造一个if - else if - else语句,正确地指定字母等级。


I am trying to construct two, one-dimensional parallel arrays that will give me a letter grade for whatever score I enter. The two arrays I need are minimum score and grade. I don''t understand how to build the score array. The scores are as follows: 0 - 299 should result in a F
300 - 349 should result in a D
350 - 399 should result in a C
400 - 449 should result in a B
450 - 500 should result in an A

I dont know how to enter the score data as a range of data.

Any kind of help/pointers on this would be greatly appreciated.

解决方案

You will need an array for maximum score for grade and an array for minimum score for grade, plus the letter grade array gives 3 arrays.

However I would not do it like that, the min score, max score and letter grade are all related to ech other. I would create a structure containing min score, max score and letter grade and then have an array of structures

Expand|Select|Wrap|Line Numbers


You will need an array for maximum score for grade and an array for minimum score for grade, plus the letter grade array gives 3 arrays.

However I would not do it like that, the min score, max score and letter grade are all related to ech other. I would create a structure containing min score, max score and letter grade and then have an array of structures

Expand|Select|Wrap|Line Numbers


Only store either the minimum or maximum value, look at your data

scores[5] = {0-299, 300-349, 350-399, 400-449, 450-500};

in all cases the maximum limit of 1 index = the minimum limit of the next index - 1

i.e.
299 = 300 - 1
349 = 350 - 1
399 = 400 - 1
449 = 450 - 1

By trying to store the maximum and minimum for each grade you are duplicating data.

You can store the maximum (or minimum the choice is yours) for each grade and from that data construct an if - else if - else statement that correctly assignes the letter grade.


这篇关于构造并行阵列的问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆