how to use stack combining with if?

E

ela

I have a set of numbers representing student IDs and these students need
special attention to their grades.

220048 311611 519804 797736 909164
a b a c e


in fact the grade file is in a format like this:

1 a
2 a
3 c
4 b
5 a
6 b
7 ...
4000000 a

I would like to use the student IDs to obtain their corresponding grades,
stack seems to be a solution but I don't know how to combine it elegantly
with "if". Does anybody have a suggestion? Thanks.
 
E

ela

ela said:
I have a set of numbers representing student IDs and these students need
special attention to their grades.

220048 311611 519804 797736 909164
a b a c e


in fact the grade file is in a format like this:

1 a
2 a
3 c
4 b
5 a
6 b
7 ...
4000000 a

Furthermore, we have to look for whether any student in particular classes
not taking the exam, e.g.

class A: 578732 578886

class B: 581965 582162

class C: 960063 960325

....

So again as I have the file
578732 578886
581965 582162
....

how can i check the presence of exam, giving that the file this time is not
with numbers monotonically increasing?
 
J

Jürgen Exner

ela said:
Furthermore, we have to look for whether any student in particular classes
not taking the exam, e.g.

class A: 578732 578886

class B: 581965 582162

class C: 960063 960325

...

So again as I have the file
578732 578886
581965 582162
...

how can i check the presence of exam, giving that the file this time is not
with numbers monotonically increasing?

Your descriptions are not clear to me at all, but the general approach
to this kind of problem is to read the shorter or less organized data
into memory, creating a data structure that is is well organized and
targeted to make the main task easier. In your case, where you want to
check if a given number appears in the "special attention list" or the
"didn't take exam" list, a hash seems to be quite convenient.
And then just loop through the larger list one by one checking if the
current element occurs in either of your predetermined check lists.

If you get even more special lists, then the opposite approach might be
more useful: reading the whole student list into memory once and then
walking through your special lists one by one.

I have no idea what you mean by "stack combining with if". Those two
have about nothing in common at all.
jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top