Software development is an extremely complex process, a small piece of code we can quickly and accurately complete, but when you are faced with a large software system, do you feel overwhelmed?
In the age of C, where programming ideas are structured, your C-language teacher may continue to teach you how to use structured methods to complete a program, and you may also know an important law in software development (Wirth law):
program = algorithm + data structure
In structured design, people usually look at this law in this way:
program = (algorithm) + (data structure)
For example: (I still use C + + standard library to write the following code, convenient and future code comparison)
#include <iostream>
using namespace Std;
typedef struct STUDENT
{
Char strname[50]; Name
int math; Math Score
int Chinese; Chinese
int total; Score
}student;
void InitData (student* some)
{
//////////////////////////////////////
Initializing data
Some->strname[0] = ' the ';
Some->math = 0;
Some->chinese = 0;
some->total = 0;
}
void Inputdata (student* some)
{
///////////////////////////////////////
Get input
cout<< "Enter Name" <<endl;
cin>>some->strname;
cout<< "Enter Math" <<endl;
cin>>some->math;
cout<< "Enter Chinese" <<endl;
cin>>some->chinese;
//////////////////////////////////////
Calculate Total Score
Some->total = Some->math + some->chinese;
}
void Printdata (STUDENT some)
{
cout<<some.strname<< "' s total mark is: <<some.total<<endl;
}
The upper part can be placed in a single head and CPP.
Main ()
{
STUDENT someone;
InitData (&someone);
Inputdata (&someone);
Printdata (someone);
}