Data structure--curriculum design--Arranging teaching plan __ data structure

Source: Internet
Author: User
Tags number strings

1. Description of the problem

Every major in the university has to develop a teaching plan. Suppose any profession has a fixed length of study, with two semesters per academic year, and the duration of each semester is equal to the upper limit of the credits. The courses offered by each professional are determined, and the arrangement of the courses in the course of time must satisfy the first-repair relationship. What are the first courses in each course are OK, can have any number of doors, also can not. Each class happens to occupy one semester. Try to design a programming program of teaching plan under such premise.

The basic features required for implementation are as follows:

(1) Input Course catalogue.

(2) You can edit the course catalogue, such as course addition, deletion, information modification and so on.

(3) The output of teaching plan satisfying certain conditions.

2. Design Requirements

(1) Basic requirements: Input parameters include: The total number of semesters, the credit limit for one semester, the course number of each course (fixed for 3 letters and number strings), credits and the course number of the direct first course.

(2) Allow the user to specify one of the following two scheduling strategies: first, to make students in the semester of learning burden as evenly as possible; the second is to make the course as much as possible in the first few semesters.

(3) If no solution is provided according to the given conditions, the appropriate information is reported; otherwise the teaching plan is exported to the user-specified file. The table format of the teaching plan is designed by itself.

3. Test data

Semester total: 8; credit limit: 10; The major is a total of 16 courses, the course number from C01~C16, credit order for 2,3,4,3,2,3,4,4,4,5,4,4,2,3,2,3; first repair relationship customization (drawing).

4. Implementation Tips

The total number of semesters may not exceed 10, and the total number of courses shall not exceed 60. If you enter a refresher course number that is not in the course sequence that is offered in the specialty, it is treated as an error. The corresponding relationship between the internal course serial number and the course number should be established.


Code (compiled by Codeblocks):

#include <bits/stdc++.h> using namespace std;
    struct Node {char name[33];
int XF;

};
int all_terms, T_MAX_XF, T_v, t_e;
Vector<node> g[1009];

Map<string, Int> MP;
    void Create_graph () {int i;
    printf ("\t\t\t welcomes use of the instructional planning system \ n");
    printf ("Enter the total number of semesters:");
    scanf ("%d", &all_terms);
    printf ("Please enter the semester's credit limit:");
    scanf ("%d", &AMP;T_MAX_XF);
    printf ("Please enter the number of courses in the teaching Plan:");
    scanf ("%d", &t_v);
    printf ("Please enter the sum (total number of sides) of the first course of each course");
    scanf ("%d", &t_e);
    printf ("Please enter the course number for%d courses (up to 30 characters, lowercase c+ digits such as C10) \ n", t_v);
    node data;
        for (i = 1; I <= t_v; i++) {printf ("Please enter%d:", i);
        scanf ("%s", data.name);
        G[i].push_back (data);
    Mp[g[i][0].name] = i;
    printf ("Please enter%d courses for each credit value: \ n", t_v);
    for (i = 1; I <= t_v i++) scanf ("%d", &AMP;G[I][0].XF);
    printf (enter end of #) by entering the following course's first course;
    Char s[33];
         for (i = 1; I <= t_v; i++) {printf ("The first course of%s:", g[i][0].name); while (trUE) {scanf ("%s", s);
             if (s[0] = = ' # ') break;
         G[i].push_back (G[mp[s]][0]);
printf ("\t\t\t entry data succeeded \ \ n");
    } void Display () {int i, J;
    printf ("Forward graph \ n");
    printf ("%d vertices", t_v); for (i = 1; I <= t_v ++i) printf ("%s%c", g[i][0].name, i = = T_v?
    ' \ n ': ');
    printf ("%d arc edge: \ n", t_e);
        for (i = 1; I <= t_v; i++) {int k = g[i].size ();
    for (j = 0; J < K; J +) printf ("%s---->%s\n", g[i][0].name, G[i][j].name);
    } void solve1 (int ans[]) {int q = 1, cnt = 0;
        while (q <= all_terms) {int num = t_v/all_terms;
        printf ("\ n the course of%d semesters:", q); while (num--) {printf ("%s%c", G[ans[cnt++]][0].name, num!= 0?)
        ': ' \ n ');
        } if (q = = all_terms) printf ("OK over!\n");
    q++;
    } void Solve2 (int ans[]) {int q = 1, cnt = 0; while (q <= all_terms) {int C = g[ans[cnt]][0].XF;
        printf ("\ n the course of%d semesters:", q);
            while (CNT < t_v && C <= t_max_xf) {printf ("%s", g[ans[cnt]][0].name);
            if (Cnt+1 < t_v) C = c + g[ans[cnt+1]][0].xf;
        cnt++;
            } if (cnt >= t_v | | q = = all_terms) {cout << Endl;
            printf ("OK over!\n");
        Break
    } q++;
    } void Topo_sort () {int I, j, vis[1009];
    memset (Vis, 0, sizeof (VIS));
        for (i = 1; I <= t_v; i++) {int k = g[i].size ();
    for (j = 1; j < K; J +) vis[mp[g[i][j].name]]++;
    int ans[1009], cnt = 0;
    memset (ans, 0, sizeof (ans));
    Stack<int> s;
    for (i = 1; I <= t_v i++) {if (!vis[i)) s.push (i);
       while (!s.empty ()) {int cur = s.top (); S.pop ();
       ans[cnt++] = cur;
       int k = G[cur].size (); for (j = 1; j < K; J +) {int num = Mp[g[cur][j].name];
           vis[num]--;
       if (!vis[num]) s.push (num);
    } if (CNT!= t_v) puts ("error!");
        else {puts ("ok!");
            while (true) {printf ("\n\t\t\t Please select feature: \ n");
            printf ("\t\t\t1. Average distribution \ n");
            printf ("\t\t\t2 allocation \ n");
            printf ("\t\t\t3. Exit \ n");
            int sel;
            scanf ("%d", &sel);
                Switch (SEL) {case 1:solve1 (ans); Case 2:solve2 (ANS);
            Break
        } if (sel = = 3) break;
    int main () {Create_graph ()}}
    Display ();
    Topo_sort ();
return 0; /* 6 C1 c2 c3 c4 c5 c6 C7 C8 C9 C10 C11 C12 2 3 4 3 2 3 4 4 7 5 2 # c1 # C1 C2 # C1 # c3 # C11 # c5 C3 # C 3 C6 # c9 # C9 # C9 C10 C1 # * * *


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.