Traditional Culture Encyclopedia - Photography major - Find a programming idea of C language

Find a programming idea of C language

Use an array of structures.

The structure should contain 6 data, the names and scores of 5 courses.

The data type of the name should be a string, and others should be integers.

Here is a simple example, which includes the definition of structure and simple application:

# include & ltstdio.h & gt

void main()

{

Structural students

{

char * name

Int Yu Wen, Shu Xue, Wuli, Huaxue, Outland;

};

Students [50];

Student [0]. name = " sss

Student [0]. Yu Wen = 40;

Student [0]. Shu Xue = 60;

Student [0]. wuli = 50

Student [0]. Huaxue = 90;

Student [0]. waiyu = 10;

Printf("% s% d% d% d% d% d% d \ n ",student [0]. Name,

Student [0]. Yu Wen,

Student [0]. Shu Xue,

Student [0]. wuli,

Student [0]. Huaxue,

Student [0]. Outland);

}

You can enter all students' data in the program or at runtime. This program had better use a database. It's too much trouble to input data for 50 students. I suggest you change it to five students. The reason is the same. ~~~~~

For the first question, if you want to display the information of a classmate after data input, first compare the names of classmates in the array.

for(n = 0; n & lt=4; n++)

{

If (student [n]. Name== "the name you entered") break

}//After execution, n is the number of the classmate.

And then output relevant information.

But there is still a problem that many students have the same name, so we should pay attention to it.

For the second question, you can use the first question to get the information of two students, and then

If (student [n]. A subject score >; = student [m]. Subject score)

{printf (student [n]). Name); }

other

{student [m]. Name; }

I just explained my thinking, and the code inside is pseudo-code. I hope it helps you.