Data structure C/C++ programming assignment writing, C++ processing English assignments

Data structure C/C++ programming assignments, C++ processing English assignments
1. Course design topics
can be selected from the following two topics to complete.
1.1 College examination registration system
College examination registration adds a lot of workload to the educational administration department. Manual entry of registration data is time-consuming and will inevitably lead to errors. At the same time, it also provides opportunities for many students. This project is a simple simulation of examination registration management. It can complete the following functions by menu selection:
(1) Input candidate information, each candidate information consists of admission ticket number (composed of five digits), name, gender, age, application subject, etc. Information composition;
(2) Output candidate information;
(3) Query candidate information;
(4) Add candidate information;
(5) Modify candidate information;
(6) Delete candidate information;
(7) Sort the examination information according to the admission ticket number .
Requirements: Friendly interface, appropriate operation prompts are given in each step, and the system has a certain fault tolerance.
1.2 Beijing Attraction Inquiry System
In tourist attractions, tourists often encounter tourists inquiring about the shortest path and shortest distance from one scenic spot to another. Such tourists do not like to visit according to the route of the guide map, but choose the scenic spots that they are interested in. tour. In order to help this kind of tourist information query, it is necessary to calculate the shortest path and shortest distance between all attractions. The establishment of a tourist information management system for Beijing scenic spots, the main functions of which include formulating strategies for tourist attractions guide routes and formulating strategies for road paving in scenic spots. The specific functional modules are as follows:
(1) Create a distribution map of scenic spots, requiring at least 10 scenic spots in the distribution map;
(2) Output the distribution map of scenic spots, represented by an adjacency matrix;
(3) Output starting from a certain point Tour guide route map;
(4) Determine whether there is a loop in the tour guide route map;
(5) Find the shortest path and shortest distance between two scenic spots;
(6) Output road construction plan.
The main program is required to use menu options for the user to select function modules, the interface is friendly, and appropriate operation prompts are given for each step, and the system has a certain fault tolerance.

2. Course design report writing specification
The course design report includes the needs analysis, outline design, detailed design, program test, impression and experience of the topic. The following uses "sparse matrix operator" as an example to illustrate how to write a course design report.

Title requirements: Design a sparse matrix calculator to implement the addition, subtraction, multiplication and transpose operations of two sparse matrices. The menu is used as the interface of the application program, and the user can realize the addition, subtraction, multiplication of the matrix and the calculation of the speed of the matrix respectively by selecting the menu.
2.1 Requirements Analysis
1. Sparse matrix refers to a matrix with a sparse factor less than or equal to 0.5. Using the "sparse" feature for storage and computing can greatly save storage space and improve computing efficiency. Implement an operator that performs basic operations on sparse matrices.
2. The sparse matrix is ​​represented by a triplet sequence table with "row logical link information", which realizes matrix transposition, and operations of addition, subtraction, and multiplication of two matrices. The input form of the sparse matrix is ​​represented by triples, and the operation results are listed in the form of arrays.
3. The demonstration program is carried out in the dialogue mode between the user and the computer, and the array is created by inputting while creating. First, enter the number of rows and columns of the matrix, and judge whether the number of rows and columns of the two matrices given matches the required operation.
4. The program can put no restrictions on the input attributes of the triples; according to the rows and columns of the matrix, the triples are sorted by insertion between them, so that no errors will be generated during the operation.
5. When using triples to represent sparse matrices, the resulting matrices produced by addition, subtraction, and multiplication are additionally generated.
6. Operating environment: VC6.0++.
2.2 Outline design
Sparse matrix elements are represented by triples:
typedef struct{
int i; // non-zero row subscript
int j; // non-zero column subscript
int e; // matrix non-zero element
}Triple ;
The sparse matrix is ​​stored in a triple order table:
#define MSXSIZE 12500 //Assume the maximum number of non-zero elements is 200
#define MAXRC 10 //Assume the maximum number of rows of the matrix is ​​10
typedef struct
{
int mu ; //the number of rows of the matrix
int nu ; //the number of columns of the matrix
int tu ; //the number of non-zero elements of the matrix
Triple data[MAXSIZE+1]; //table of non-zero triples , data[0] is not used
int rpos[MAXRC+1]; //Position table of the first non-zero element of each row
}Tabletype; The
main functions and functions of the system are as follows:
Menu( ): main control menu, receiving user's options;
Input_Matrix( ): Input matrix;
Print_matrix( ): Output matrix;
Cal_matrix( ): Calculate the bit number of the first non-zero element in each row of the matrix in the triplet;
TransposeMatrix( ): Matrix transpose;
Add_Matrix( ): Matrix Addition operation;
Sub_Matrix( ): Matrix subtraction operation;
Multi_Matrix( ): Matrix multiplication operation.
The calling relationship of the modules is shown in Figure 1.

Figure 1 Schematic diagram of program calling module

2.3 Detailed design
1. Main function design

//********************************************
//* Matrix operation main function *
//********************************************
In the main function, realize the user Print the menu menu, and execute the corresponding function according to the user's options. The main function strives to be concise and clear.
void main( )
{
num=Menu(); //Print the main menu
while(num)
{
switch(num)
{
case 1:
Multi_Matrix(); //Matrix multiplication
break;
case 2:
TransposeMatrix(); //Matrix Transpose
break;
case 3:
Add_Matrix(); //Matrix addition
break;
case 4:
Sub_Matrix(); //Matrix subtraction
case 0:
break;
}//switch
num=Menu();
}//while
}
2. main menu design
The main control menu is used to output prompt information and process input. This function returns the user's options, which are provided to the switch statement in the main function. For options that do not meet the requirements, prompt for input errors and require the user to re-enter. Combine this function with the main function, compile and run the program, and you can check and verify that the menu options are correct.
The main menu is as follows:
//********************************************
//* print main menu function*
//********************************************
int menu( )
{
printf("\n Main Menu");
printf("\n************************");
printf("\n 1. Matrix Multiplication");
printf("\n 2. Matrix Transpose");
printf("\n 3. Matrix Addition");
printf("\n 4. Matrix Subtraction");
printf("\n 0. Exit ");
printf("\n********************");
scanf("%d",&num);
while(num<0||num >4) //Illegal input, re-enter
scanf("%d",&num);
return num;



//* Matrix multiplication algorithm*
//**************************************** *

Status Multi_Matrix()
{
Input_Matrix(&a); //Input matrix a
Input_Matrix(&b); //Input matrix b
Cal_matrix(&a); //Calculate the bit number of the first non-zero element in each row of matrix a
Cal_matrix(&b) ; //Calculate the bit number of the first non-zero element of each row of matrix b
if (a.nu!=b.mu) //Does not meet the conditions of matrix multiplication and cannot be multiplied
return ERROR;
c.mu=a.mu; //Initialize the matrix c
c.nu=b.nu;
c.tu=0;
if(a.tu*b.tu!=0){
for(arow=1;arow<=a.mu;arow++){ /*Process each row of matrix a*/
for (p=1;p< MAXRC+1;p++) /*Clear the accumulator of each element in the current row*/
ctemp[p]=0;
c.rpos[arow]= c.tu+1;
if(arow<a.mu )
tp=a.rpos [arow+1];
else
tp=a.tu +1;
for(p=a.rpos[arow]; p<tp;p++ ){ //Get the non-zero element of the crow row in c
brow=a.data[p].j;
if(brow<b.nu)
t=b.rpos[brow+1];
else
t=b.tu+1;
for (q=b.rpos[brow];q<t;q++){
ccol=b.data[q].j; /*the column number of the product element in matrix c*/
ctemp[ccol]+=a.data[p].e*b.data[q].e;
} /*for q*/
}//for p
for(ccol=1;ccol<=c.nu;ccol++ )
if(ctemp[ccol]) /*compressed and stored non-zero elements of the row*/
{
if((c.tu)>MAXSIZE)
exit(1);
c.tu++;
c.data[c.tu].i= arow;
c.data[c.tu].j=ccol;
c.data[c.tu].e=ctemp[ccol];
}/*end if*/
}/*for arrow*/
}/*if* /
Print_matrix(a);
Print_matrix(b);
Print_matrix(c);
}
4. Matrix transpose algorithm
//**************************** ****************
//* Matrix transpose algorithm*
//************************ ****************
void TransposeMatrix(){
Input_Matrix(&a); //input matrix a
b.mu=a.nu;
b.nu=a.mu;
b.tu=a.tu;
if(b.tu){
q=1; /*b.data subscript*/
for(col=1;col<=a.nu;col++) //for each column of a
for(p=1;p<=a.tu;p++) /*p It is the subscript of a*/
if( a.data[p].j==col){ //Look for the non-zero elements in the column a of the matrix a.
b.data[q].i=a.data[p] .j ;
b.data[q].j=a.data[p].i;
b.data[q].e=a.data[p].e;
q++;
}//if(p)
}/ /if(b.tu)
Print_matrix(b); //Output the transposed matrix of a
}
5. Matrix addition algorithm
//********************** ********************
//* Matrix addition function*
//* c=a+b *
//************ ****************************
Status Add_Matrix(){
Input_Matrix(&a); //input matrix a
Input_Matrix(&b); //输入矩阵b
if(a.mu !=b.mu ||a.nu !=b.nu ) //不满足矩阵加法条件
return ERROR;
c.mu =a.mu ;
c.nu =a.nu ;
ta=1; tb=1; tc=1;
if(a.tu *b.tu !=0){
while((ta<=a.tu) && (tb<=b.tu)){
if(a.data[ta].i==b.data[tb].i){
if(a.data[ta].j==b.data[tb].j){
temp=a.data[ta].e+b.data[tb].e;
if(temp!=0){
c.data[tc].i=a.data[ta].i;
c.data[tc].j=a.data[ta].j;
c.data[tc].e=temp;
tc++;
}//end if (temp)
ta++; tb++;
}//end if
else{
if(a.data[ta].j<b.data[tb].j){
c.data[tc].i=a.data[ta].i;
c.data[tc].j=a.data[ta].j;
c.data[tc].e=a.data[ta].e;
ta++; tc++;
}//end of else if
else{
c.data[tc].i=b.data[tb].i;
c.data[tc].j=b.data[tb].j;
c.data[tc].e=b.data[tb].e;
tb++; tc++;
}//
}
}//end if
else{
if(a.data[ta].i<b.data[tb].i){
c.data[tc].i=a.data[ta].i;
c.data[tc].j=a.data[ta].j;
c.data[tc].e=a.data[ta].e;
tc++; ta++;
}
else{
c.data[tc].i=b.data[tb].i;
c.data[tc].j=b.data[tb].j;
c.data[tc].e=b.data[tb].e;
tc++; tb++;
}
}
}//while
while(ta<=a.tu){ //处理a中剩余非零元
c.data[tc].i=a.data[ta].i;
c.data[tc].j=a.data[ta].j;
c.data[tc].e=a.data[ta].e;
tc++; ta++;
}
while(tb<=b.tu){ //Process the remaining non-zero elements in b
c.data[tc].i =b.data[tb].i;
c.data[tc].j=b.data[tb].j;
c.data[tc].e=b.data[tb].e;
tc++; tb++;
}
}//
c.tu=tc;
Print_matrix(c);
}
6. The matrix input algorithm is
used to input the number of rows, columns, non-zero elements, and each non-zero element of the matrix. The input algorithm is as follows:
//********************************************
//* Matrix Input Algorithm*
//********************************************
Status Input_Matrix( Tabletype *t)
{
scanf(t->mu, t->nu, t->tu); //Get the number of rows and columns of the matrix and the number of non-zero elements
for(i=1;i<=tu;i++)
scanf( t->data [i].i, t->data [i].j,t->data [i].e);
return OK;
}
7. Matrix output algorithm
Output the triplet on the screen in a matrix, the algorithm is as follows:
//******************************** ********
//* Matrix output function*
//************************************ ********
Status Print_matrix(Tabletype m){
k=1;
for(i=1;i<=m.mu;i++){
for(j=1;j<=m.nu ;j++) {/*Non-zero elements*/
if((m.data[k].i==i)&&(m.data[k].j==j)){
printf(m.data[k].e) ;
k++;
}
else
printf("0"); /*zero element*/
}
printf("\n");
}
}
8. Cal_matrix function
needs to count the first non-zero element in each row of the matrix when multiplying the matrix The bit number in the triple table, the algorithm is as follows:
void cal_matrix(Tabletype *m){
//Calculate the bit number of the first non-zero element in each row in the matrix
for(row=1;row<=m-> mu ;row++)
num[row]=0;
for(t=1;t<=m->tu ;t++)
num[m->data [t].i]++;
m->rpos [1]=1;
for(row=2;row<=m->mu ;row++)
m->rpos [row]=m->rpos [row-1]+num[row-1] ;
}
2.4 Program Testing
In this section, screen shots of program running results and test analysis are given.
2.5 Impressions and Experiences
This part presents the problems in the algorithm design process, the problems and gains in the program debugging process.
3. Requirements
The source program has no syntax errors and the running results are correct;
the design report is written in accordance with the specifications.
The final submission of course design includes: source program and course design report.
http://www.daixie0.com/contents/13/1307.html

 

Our field of direction: window programming, numerical algorithm, AI, artificial intelligence, financial statistics, econometric analysis, big data, network programming, WEB programming, communication programming, game programming, multimedia linux, plug-in programming program, API, image processing, embedded/MCU database programming, console process and thread, network security, assembly language hardware Programming software design engineering standards and regulations. The ghostwriting and ghostwriting programming languages ​​or tools include but are not limited to the following:

C/C++/C# ghostwriting

Java ghostwriting

IT ghostwriting

Python ghostwriting

Tutored programming assignments

Matlab ghostwriting

Haskell ghostwriting

Processing ghostwriting

Building a Linux environment

Rust ghostwriting

Data Structure Assginment

MIPS ghostwriting

Machine Learning homework ghostwriting

Oracle/SQL/PostgreSQL/Pig database ghostwriting/doing/coaching

web development, website development, website work

ASP.NET website development

Finance Insurance Statistics Statistics, Regression, Iteration

Prolog ghostwriting

Computer Computational method

 

Because professional, so trustworthy. If necessary, please add QQ: 99515681 or email: [email protected]

WeChat: codinghelp

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325171775&siteId=291194637