achievement
Course design report book
20 09 ~ 20 10 second semester of school year
Course name: C language course design
Teacher:
Class level: B090602
Last name: Zang Fuyue
Student ID: B09060243
20 June 10
First, the curriculum design topic: perpetual calendar
Two. Title requirements:
When the (1) program starts running, the current almanac will be displayed.
(2) The monthly calendar can be displayed according to the entered year.
(3) When the year less than 1900 is entered, exit the program.
Three. Topic analysis:
Theme analysis and functional module division of curriculum design.
(1) First, judge the day of the first day of each year according to the starting year, and then control the spatial output of the first line of each month according to the day of the week!
(2) Judge whether each year is a leap year, and set relevant February days!
4. Module design (flow chart):
Design description of each module, including the description of module name, function, entry parameters and return value, and the description of the implementation process of each module (draw a flow chart if necessary).
(1)main function: this function is the program entry. When the number of years entered is less than 1900 through a do-while, the program exits; otherwise, the main function calls the classify function and passes the number of years entered as a parameter to the classify function!
(2)calculate function: this function has one parameter, which is the input year passed in by the main function, and the return type is void. This function is responsible for receiving the input year from the main function and displaying it, and then calling the standpirnt function.
(3)standpirnt function: This function has one parameter, which is the input year passed in by the calculate function, and the return type is void. This function is responsible for the output of standard calendar format, setting the number of days in each month according to the number of cycles, and controlling the space at the beginning of each month through tag and tag2! And call dayOfweek to get the day of the week on the first day of the input year, and output the corresponding space!
(4)dayOfweek function: this function has one parameter, which is the number of years entered, and the return value is the day of the week. This function is responsible for returning a day of the week as the first day of the year, and outputting many spaces matching that day!
Verb (abbreviation of verb) source code:
The source code of each module.
Main functions:
void main() {
int input = 0;
int Jude = 1;
Do {
Printf ("Please enter the year! \ n ");
Scanf("%d ",& input);
If (input < =1900) {
Printf ("Data error! ! !" );
Jude = 0;
}
Printf ("year is %d\n", input);
//Here, judge whether it is a leap year!
If (Jude)
Calculation (input);
} while (Jude);
}
*************************************************************
Calculation function:
//This function is responsible for displaying the year and calling the standpirnt function!
Invalid calculation (inter-year) {
Printf("%d\n ",year);
Standpirnt (year);
//day ofweek(year);
}
Excellent function
Invalid period (inter-year) {
//Test the calendar format output here!
int date[3 1]= { 0 };
for(int I = 0; I<3 1; i++) {
Date [I] = I+1;
}
Int input = year;
int tag = 0;
int tag 2 = 0;
int leap = 0;
int ccyd = 0;
int bug = 0;
for(int j = 0; j & lt 12; j++) {
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf(" %d year %d month \n ",input, (j+1));
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
printf(" Day 123456 \ n ");
//Set the number of days in a month!
if(input % 4 = = 0 | | input % 100 = = 0 & amp; & enter %400! = 0)ccyd = 1;
Switch ((j+1)) (
Case1:leap = 31; Break;
Case 2: ccyd? Leap = 29: leap = 28; Break;
Case 3: leap = 31; Break;
Case 4: leap = 30; Break;
Case 5: leap = 31; Break;
Case 6: leap = 30; Break;
Case 7: leap = 31; Break;
Case 8: leap = 31; Break;
Case 9: leap = 30; Break;
Case10: leap = 31; Break;
Case 1 1: leap = 30; Break;
Case12: leap = 31; Break;
}
//Jump and line break are controlled here!
for(int k = 0; K< leap; k++) {
if(k = = 0 & amp; & ampj == 0) {
Tag = dayOfweek (input);
if(tag = = 7)tag = 0;
}
else if(k==0) {
Switch (Label 2) {
Case 0: printf (""); Break;
case 1:printf(" "); Break;
Case 2: printf (""); Break;
Case 3: printf (""); Break;
Case 4: printf (""); Break;
Case 5: printf (""); Break;
Case 6: printf (""); Break;
}
}
printf("%3d ",date[k]);
tag++;
//newly added
if(date[k] == leap) {
tag 2 = tag- 1;
}
if(tag==7) {
printf(" \ n ");
tag = 0;
}
}
printf(" \ n ");
}
}
DayOfweek function:
//This function is responsible for judging the day of the week when the number of years is entered!
int dayOfweek(int dayy) {
int value = 0;
int input2 = dayy
int start = 1990;
int days = 1;
Days = Enter 2-Start;
int total = 0;
int years[ 100000]= { 0 };
for(int I = 0; I< days; i++) {
Year [i] = start+I;
if(years[I]% 4 = = 0 | |(years[I]% 100 = = 0 & amp; & Year [I] %400! =0)) {
//printf ("This year is a leap year!" );
Total+= 366;
}
Otherwise {
//Pingnian!
Total+= 365;
}
}
int week = total % 7;
Switch (Week) {
Case 0: Value =1;
printf(" "); Break;
Case 1: value = 2;
printf(" "); Break;
Case 2: value = 3;
printf(" "); Break;
Case 3: value = 4;
printf(" "); Break;
Case 4: Value = 5;
printf(" "); Break;
Case 5: Value = 6;
printf(" "); Break;
Situation 6: Value = 7;
printf(" "); Break;
}
Return value;
}
Testing and debugging intransitive verbs;
Design the test methods and schemes of the system and each module.
(1) After completing the main function, observe whether the program exits by entering a function less than 1900 to test whether the main module of the program is normal!
(2) After completing the calculate function, call the calculate function in main, output relevant information in the calculate, and judge whether the calculate function is normal!
(After the standpirnt function is completed, call it in the calculate function to observe whether the calendar format output on the console is correct!
(4) After completing the dayOfweek function, call it in the standpirnt function, and finally observe the output!
Seven. Summary of course design:
(1) Through the course design, enhance the understanding and mastery of function call and line break jump in C language.
(2) Deepen the understanding of process-oriented programming!
(3) Deeply understand the concrete realization of perpetual calendar!