1.2
#include <stdio.h> const int N = 5 ; // definition of the structure type struct student, and define its alias STU typedef struct Student { long no; char name[20]; int score; }STU; // function declaration void INPUT (the STU S [], int n-); int findMinlist (the STU S [], the STU T [], int n-); void Output (the STU S [], int n-); int main () { STU stu[N], minlist[N]; int count; the printf ( " enter student information% d \ n- " , N); input(stu, N); printf ( " \ the n-lowest score statistics and the number of student information ... \ the n- " ); count = findMinlist(stu, minlist, N); printf ( " \ a total of% d the n-th lowest score, the following information: \ the n- " , COUNT); output(minlist, count); return 0; } // input n students information stored in an array of structures in s void INPUT (the STU s [], int n) { int i; for(i=0; i<n; i++) scanf("%ld %s %d", &s[i].no, s[i].name, &s[i].score); } // S n elements in the structure information output void Output (the STU S [], int n) { int i; for(i=0; i<n; i++) printf("%ld %s %d\n", s[i].no, s[i].name, s[i].score); } // In the structure of the array s, find the lowest grade recording, which is stored in an array of structures in s // parameter n s is the array of structures in the number of elements // enrollment function returns the lowest points int findMinlist (the STU S [], the STU T [], int n-) { int i,j,min=s[0].score; for(i=0;i<n;i++) { if(s[i].score<min) min=s[i].score; } i=0; for(j=0;j<n;j++) { if(s[j].score==min) t[i++]=s[j]; } return i; }
1.3
#include <stdio.h> #include <string.h> const int N = 10; // definition of the structure type struct student, and to define an alias for the STU typedef struct Student { Long int ID; char name [ 20 is ]; a float Objective; / * objective test score * / a float subjective; / * operation questions score * / a float SUM; char Level [ 10 ]; }STU; // function declaration void INPUT (the STU S [], int n-); void Output (the STU S [], int n-); void Process (the STU S [], int n-); int main () { Stu [N]; the printf ( " input candidate information of% d: ticket number, name, title objective score (<= 40), operating questions score (<= 60) \ n- " , N); input(stu, N); the printf ( " \ n-processed information on the candidates: score calculation, to determine the level \ n- " ); process(stu, N); printf ( " \ the n-Print candidates complete information: ticket number, name, objective scoring title, operating questions score, score, rank \ the n- " ); output(stu, N); return 0; } // input candidate information: ticket number, name, title and objective scores, the score operation questions void INPUT (the STU S [], int n-) { int i; for(i=0;i<n;i++) scanf("%d %s %f %f",&s[i].id,s[i].name,&s[i].objective,&s[i].subjective); } // output candidates complete information: ticket number, name, title and objective scores, operation title, TOT, grade void Output (the STU S [], int n-) { int i; for(i=0;i<n;i++) printf("%ld %s %.2f %.2f %.2f %s\n",s[i].id,s[i].name,s[i].objective,s[i].subjective,s[i].sum,s[i].level); } // candidates for processing information: overall score, sort, rank determining void Process (the STU S [], int n-) { int i,j,k; STU temp; for(i=0;i<n;i++) s[i].sum=s[i].subjective+s[i].objective; for(j=0;j<n-1;j++) { for(k=0;k<n-j-1;k++) { if(s[k].sum<s[k+1].sum) { temp=s[k];s[k]=s[k+1];s[k+1]=temp; } } } i=0; for(i=0;i<n;i++) { if(i==0) strcpy(s[i].level,"优秀"); else if(i>=1&&i<=4) strcpy(s[i].level,"合格"); else if(i>=5&&i<=9) strcpy (S [I] .level, " failure " ); } }
part 2
And it is distinguished from the common structure of the type?
A: The difference between the common body and are distinguished by their structure representation. Members structures in the body, the structure of the storage order, each member has its own separate memory locations, for the case of a union of several different types of variables with a shared memory area.
part 3
Enumeration type is used to describe what kind of data?
A: The enumeration is discrete, limited set of data. Enumerated type suitable for variable values limited circumstances.
Note the use of enumeration process:
whether the direct input and output?
You can put an int value assigned to a variable of type enum? Conversely it?
A: You can not can not can not
Sui Suinian:
Closing may be linked to the C language to kill me!
Peer assessment:
https://www.cnblogs.com/WPA1/p/10999591.html
https://www.cnblogs.com/shauifan/p/11000699.html
https://www.cnblogs.com/holya/p/11000245.html