Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Homework help

Name: Anonymous 2010-11-03 21:00

In my class we have an assignment in which we change GPA to Student Name. I've not done any work with names in c++ (my major has nothing to do with programing) but here is the default:

bool studentDB::addStudent(int num, double GPA) {
    
   int i;
    
   if(numStudents==MAXSTUDENTS) return false; // database is full
  
   for(i=0;i<numStudents;i++) {
          
      if(si[i].number==num) return false; // student already in database
     
      if(si[i].number>num) { // slide the rest of the students to the right and insert student here
         for (int j=numStudents;j>i;j--) {
            si[j] = si[j-1]; // move student one to the right
         }
         break;
      }
   }
  
   // insert student in correct place (if break above) otherwise add student at end
   si[i].number = num;
   si[i].GPA = GPA;
   numStudents++; // we've added a student
   return true; // success
}

and what I assume I should change it to (I can't compile and test yet since I have to make a new .h and .cpp for new classes and stuff). Note that our teacher gave a file called stdstuff.h and string2002 is used for characters.

bool studentDB::addStudent(int num, const String2002 &name) {
    
   int i;
    
   if(numStudents==MAXSTUDENTS) return false; // database is full
  
   for(i=0;i<numStudents;i++) {
          
      if(si[i].number==num) return false; // student already in database
     
      if(si[i].number>num) { // slide the rest of the students to the right and insert student here
         for (int j=numStudents;j>i;j--) {
            si[j] = si[j-1]; // move student one to the right
         }
         break;
      }
   }
  
   // insert student in correct place (if break above) otherwise add student at end
   si[i].number = num;
   si[i].name = name;
   numStudents++; // we've added a student
   return true; // success
}

Thanks

Name: Anonymous 2010-11-03 21:08

There isn't even a question in this post. Just some asshole who can't figure out code tags hoping we'll do their homework.

Name: Anonymous 2010-11-03 21:12

>>2
I have no idea if that will work or not and i've never done anything like this. Our prof teaches us like we have a c++ foundation but a lot of us have 0 experience with coding (in before what are you doing on 4chan).

Name: Anonymous 2010-11-03 21:28

>Homework
>java
well now you made 2 mistakes

Name: Anonymous 2010-11-03 21:28

Everything was covered already in >>2

Name: Anonymous 2010-11-03 21:40

This isn't java, this is c++

Name: Anonymous 2010-11-03 21:44

ENTERPRISE C

#define ONE 1
#define ZERO 0
#define MAXESTUDIENTES (ONE + (ONE + (ONE) + ONE) + ONE)*ZERO/ONE*ONE
typedef struct{
    int num;
    char *anus;
}FAGGOTS;



int addStudent(int num,char *anus){
    int i,j;
    if(numStudents>=MAXESTUDIENTES) return ONE;
   
    for(i=ZERO;i<numStudents;i++){
        if(si[i].number==num) return ONE;
        if(si[i].number>num){
            for(j=numStudents;j>i;j--)
                si[j] = si[j-ONE];
            break;
        }
    }
   
    si[i].number = num;
    si[i].name = calloc(sizeof(anus),sizeof(char));
    for(j=0;i<sizeof(anus);i++)
        si[i].name[j]=anus[j];
    numStudents++;
    return ZERO;
}

Name: Anonymous 2010-11-03 21:44

>>6
and there's your 3rd mistake

Name: Anonymous 2010-11-03 22:03

1. Make pseudocode
2. Logic check it
3. ???
4. Your a fag!

Name: Anonymous 2010-11-03 22:09

>>7
made me laugh.

Name: Anonymous 2010-12-28 2:35


Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List