示例#1
0
int main()
{
	srand((unsigned)time(NULL));
	
	Student* students[100] ;
	for (int i = 0; i < 100; ++i) {
		students[i] = createStudent();
	}

	for (int i = 0; i < 100; ++i) {
		destoryStudent(students[i]);
	}
	return 0;
}
示例#2
0
int DBimpl::insertStudents()
{

    QSqlQuery qry;

    qry.prepare("SELECT * FROM Students");
    if (!qry.exec())
        throw generateException(qry);
    else{
        if (!qry.next())
        {
            int num_students = 25;
            QString usernamePrefix = "Student";
            Student* tempStudent;
            Qualification* qual;
            QList<Qualification*> qualList;
            for (int i = 0; i < num_students;i++)
            {
                tempStudent = new Student(-1,usernamePrefix+(65+i));

                createStudent(*tempStudent);

                qualList = getAllQualifications(tempStudent->getID());

                for (int i = 0;i < qualList.count();i++)
                {
                    qual = qualList.at(i);

                    qual->setExpectationRating(1 + (std::rand() % (int)(5- 1 + 1)));
                    qual->setQualificationRating(1 + (std::rand() % (int)(5 - 1 + 1)));

                    createQualificationEntry(tempStudent->getID(),*qualList.at(i));


                }





            }
        }
    }
    return 1;
}
int main(void){
    struct Student * ps;
    ps = createStudent();
    
    return 0;
}
示例#4
0
文件: main.c 项目: r0sen/r0sen
void hello()
{
    int done =1;
    while (done)
    {
        system("cls");
        HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
        COORD pos;
        int i;
        char str[100];
        pos.X = 30;
        pos.Y = 10;
        SetConsoleCursorPosition(handle, pos);
        printf("Commands: ");
        pos.X = 30;
        pos.Y = 11;
        SetConsoleCursorPosition(handle, pos);
        printf("1. Take a look at list of students (list)");
        pos.X = 30;
        pos.Y = 12;
        SetConsoleCursorPosition(handle, pos);
        printf("2. Change student (change)");
        pos.X = 30;
        pos.Y = 13;
        SetConsoleCursorPosition(handle, pos);
        printf("3. Add new student (add)");
        pos.X = 30;
        pos.Y = 14;
        SetConsoleCursorPosition(handle, pos);
        printf("Exit(exit)");
        editPlace();
        gets(str);
        if (strcmp(str, "list")==0)
        {
            showList();
        }
        else if (strcmp(str, "change")==0)
        {
            changeStudent();
        }
        else if (strcmp(str, "add")==0)
        {
            createStudent();
        }
        else if (strcmp(str, "exit")==0)
        {
            done = 0;
        }
        else
        {
            system("cls");
            pos.X = 30;
            pos.Y = 10;
            SetConsoleCursorPosition(handle, pos);
            printf("Wrong command");
            pos.X = 1;
            pos.Y = 20;
            SetConsoleCursorPosition(handle, pos);
            system("pause");
        }
    }


}
示例#5
0
int main(){
	student_t *head, *newStudent,*temp;
	int age,major; 
	float gpa;
	char * name, *name1, cr;
	char *msg;
	int i;
	int answer,data;
	
	head = NULL;
	printf("You are now entering the student zone!\n");

	answer = menu();
	while(answer != 7){
		switch (answer) {
			case 1:
				printf("enter age:\n");
				scanf("%d%c",&age,&cr);
				printf("enter gpa:\n");
				scanf("%f%c",&gpa,&cr);
				printf("enter major:\n");
				scanf("%d%c",&major,&cr);
				printf("enter name:\n");
				name = getline();
				//printf("length: %d\n",strlen(name));
				newStudent = createStudent(age, name,major,gpa);
				break;
			case 2:
				insertStudent(&head,newStudent);
				break;
			case 3:
				printf("enter student name to delete\n");
				name1 = getline();
				deleteStudent(&head,name1);
				free(name1);
				break;
			case 4:
				printf("enter student name to investigate\n");
				name1 = getline();
				data = dataMenu();
				switch (data) {
					case 1:
						temp = findStudent(head, name1);
						if(temp == NULL){
							printf("Student %s not found \n",name1);
							break;
						}
						age = getAge( temp);
						printf("The age of %s, is %d\n",name1,age);
						break;
					case 2:
						temp = findStudent(head, name1);
						if(temp == NULL){
							printf("Student %s not found \n",name1);
							break;
						}
						gpa = getGpa( temp);
						printf("The gpa of %s, is %f\n",name1,gpa);					
						break;
					case 3:						
						temp = findStudent(head, name1);
						if(temp == NULL){
							printf("Student %s not found \n",name1);
							break;
						}
						major = getMajor( temp);
						printf("The gpa of %s, is %d\n",name1,major);					
						break;
						
					default:
						break;
				}
				break;
			case 5:
				temp = head;
				while(temp != NULL){
					msg = toString( temp);
					printf("%s\n",msg);
					temp = temp->link;
				}
				break;
			case 6:
				insertStudentRear(&head,newStudent);
				break;			
			default:
				break;
		}
		answer = menu();
	}
	printf("BYE\n");
	return(0);

}