C language curriculum design simple word learning system

I helped my brother write a simple lesson design topic. The time is limited (two hours). Please be careful, hehe

catalogue

Zero. Subject requirements

1, Import function library, definition structure and function declaration

2, First level menu function

3, Secondary menu function

1. Thesaurus update system

2. Learning system

4, Function implementation function

1. Related to thesaurus update

2. Learning system related

① Question answer

② Word learning

5, Main function and summary

Zero. Subject requirements

1. Specific functions
① Establish Thesaurus: establish 20 groups of word thesaurus and phrase thesaurus, which can delete and add entries.
② Word learning statistics and promotion: in the first level of English word learning, you should answer 10 questions correctly and the correct rate is more than 80%
Advance to the next level and relearn if you don't meet the conditions.
(rand(),#include<stdio. h> Structure, file or array)
2. Step by step implementation
① Preliminarily complete the overall design, set up the framework, determine the man-machine dialogue interface and determine the number of functions;
② Establish word thesaurus and phrase thesaurus, which can be deleted and added;
③ Complete word learning function, with statistics, upgrading and relearning functions;
3. Requirements
① Programming with C language;
② Use the structure to process relevant information;
③ Each functional module of the system is required to be realized in the form of function;

1, Import function library, definition structure and function declaration

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>

//Define word structure 
typedef struct word{
	char e[100];
	char c[100];
}word;
//Define word library 
typedef struct word_list{
	word list[20];
	int length;
}word_list;
word_list Word;//To avoid using pointers, create a word library space directly here
void create();
int max(int,int);
void add();
void del();
void pr();
void update();
int exc(int);
int wordlearn(int);
void startLearn(int);

2, First level menu function

//Main menu 
int menu(){
	int n;
	int flag = 1;
	while(flag){
	printf("*********Welcome to the primary school English learning system*********\n");
	printf("*********1.New thesaurus 2.Update Thesaurus********\n");
	printf("*********3.Start learning 4.sign out    ********\n");
	printf("**********************************************\n");
	scanf("%d",&n);
	switch(n){
		case 1: 
		create();
		break;
		case 2:
		update(); 
		break;
		case 3:
		startLearn();
		break;
		case 4:
		flag = 0;
		printf("Exit succeeded!\n");
		break;
		default:
		printf("Input error!\n");
		}
   }
}

3, Secondary menu function

1. Thesaurus update system

//Update system 
void update(){
	int flag = 1;
	int n;
	while(flag){
		printf("*******Update system*******\n");
		printf("****1.Add word 2.Delete word*****\n");
		printf("****3.View thesaurus 4.sign out ********\n");
		scanf("%d",&n);
		switch(n){
			case 1:
				add();
				break;
			case 2:
			    del(); 
			    break;
			case 3:
				pr();
				break;
			case 4:
				flag = 0;
				break;
			default:
				printf("Input error!\n");
				 
		}
	}
}

2. Learning system

//learning system  
void startLearn(){
	int flag = 1;
	int n;
	int score = 0;
	int grade = 1; 
	while(flag){
		printf("*******learning system ********\n");
		printf("***1.Word learning 2.Phrase learning******\n");  //Realization of phrase learning
		printf("***3.Level view 4.Title View******\n");
		printf("***0.Exit the system  *****\n");
		scanf("%d",&n);
		switch(n){
			case 1:
				score = max(score ,wordlearn(grade));
				if(score >= 80 && grade < 2){
					grade++;
				}
				break;
			case 2:
				break;
			case 3:
				printf("What is your current level%d\n",grade);
				break;
			case 4: //It's too lazy. Just put it up
			    if(grade == 1){
			    	printf("No title\n");
			    	break;
				} 
				printf("What is your current title:\n");
				if(grade > 1){
					printf("fledgling\n");
				}
				if(score == 100){
					printf("Peak of life\n");
				}
				break;
			case 0:
				flag = 0;
				break;
			default:
				printf("Input error!\n");
		}
		
	}
}

4, Function implementation function

1. Related to thesaurus update

//Create word library 
void create(){
	Word.length = 0;
	printf("Created successfully!\n"); 
}
//Maximum function 
int max(int a , int b){
	return a > b ? a:b;
}
//Add words 
void add(){
	printf("Please enter English and Chinese words(Line feed input): \n");
	scanf("%s%s",Word.list[Word.length].e,Word.list[Word.length].c);
	Word.length++;
}
//Delete word 
void del(){
	printf("Please enter the serial number of the word to be deleted:\n");
	int n,j;
	scanf("%d",&n);
	if(n > Word.length){
		printf("The word was not found!\n");
		return;
	}
	for(j = n-1 ; j < Word.length-1 ; j++){
		Word.list[j] = Word.list[j+1];
	}
	Word.length--;
	printf("Delete succeeded!\n");
}
//Print word library 
void pr(){
	if(Word.length == 0){
		printf("No words in thesaurus!\n");
	}
	printf("******Word thesaurus content******\n");
	
	int i;
	for(i = 0 ; i < Word.length ; i++){
		printf("%s  %s\n",Word.list[i].e,Word.list[i].c);
	}
}

2. Learning system related

① Question answer

//Answer the question 
int exc(int grade){
	srand(time(0));
	int number = 0;
	int score = 0;
	int r;
	char temp[100];
	//Level 1 
	if(grade == 1){
		while(number < 10){
			r = rand()%10 + 1;
			printf("Britain:%s\n",Word.list[r].e);
			printf("in:");
			scanf("%s",temp);
			if(strcmp(temp,Word.list[r].c) == 0){
				score += 10;
				printf("Correct answer!\n");
			}else{
				while(1){
					printf("Wrong answer! Please answer again:\n");
					scanf("%s",temp);
					if(strcmp(temp,Word.list[r].c) == 0){
						printf("The answer is correct, but not once, so no extra points!\n");
						break;
					}
				} 
			}
			number++;
		}
	}
	//Level 2 
	if(grade == 2){
		while(number < 10){
			r = rand()%10 + 11;
			printf("Britain:%s\n",Word.list[r].e);
			printf("in:");
			scanf("%s",temp);
			if(strcmp(temp,Word.list[r].c) == 0){
				score += 10;
				printf("Correct answer!\n");
			}else{
				while(1){
					printf("Wrong answer! Please answer again:\n");
					scanf("%s",temp);
					if(strcmp(temp,Word.list[r].c) == 0){
						printf("The answer is correct, but not once, so no extra points!\n");
						break;
					}
			}
			number++;
		}
	}
	return score; //Return score 
}
}

② Word learning

//Word learning 
int wordlearn(int grade){
	int score = 0;
	int flag = 1;
	while(flag){
	printf("Please select:\n");
	printf("1.Learning 2.sign out\n");
	int n ;
	scanf("%d",&n);
	switch(n){
		case 1:
			score = max(score,exc(grade));
			break;
		case 2:
			flag = 0;
			break;
		default:
			printf("Input error!\n");
	}
    }
    return score;
}

5, Main function and summary

int main(){
	menu();
	return 0;
}

Hey, hey, the phrase learning module has not been realized. You can try it. My brother said it late and the time is urgent. It should be OK. I wish him a smooth reply, ha ha ha

Keywords: C Programming

Added by elnino on Wed, 05 Jan 2022 03:15:49 +0200