7-1 Calculating Employee Wages
1. Design ideas
(1) Mainly describe the topic algorithm
① It is required to write a program to sequentially output the name and actual salary of each employee (actual salary = basic salary + floating salary - expenditure)
②Basic salary, floating salary, and expenditure are all related to a certain employee, so a structure can be defined
③Use the for loop to input the information
④Use the for loop to output sequentially
(2) Flowchart
#include<stdio.h> struct worker { char name[10]; float jb,fd,zc; float fee; }; intmain() { struct worker w[10]; int N,i; scanf("%d",&N); for(i=0;i<N;i++) { scanf("%s %f %f %f",w[i].name,&w[i].jb,&w[i].fd,&w[i].zc); w[i].fee=w[i].jb+w[i].fd-w[i].zc;} for(i=0;i<N;i++){ printf("%s %.2f\n",w[i].name,w[i].fee); } }
3. Problems encountered in the debugging process of this question and solutions
Error message 1:
No error Reason: No
Correction method: No
https://coding.net/u/aggresiver/p/123/git/blob/master/7-10
7-2 Calculate the grade point average
1. Design ideas
(1) Mainly describe the topic algorithm
① Ask to calculate their average grades and output the list of students below the average in order
②Define the structure
③Use the for loop to input the basic information of the students
④Use the for loop again to judge
2. Experimental code
#include<stdio.h> struct student { char No[6]; char name[10]; int sore; }; intmain() { int N,i,sum=0; double avg; struct student s[10]; scanf("%d",&N); for(i=0;i<N;i++) { scanf("%s %s %d",s[i].No ,s[i].name ,&s[i].sore ); sum=sum+s[i].sore ; } avg = sum * 1.0 / N; printf("%.2lf\n",avg); for(i=0;i<N;i++) { if(s[i].sore<avg) printf("%s %s\n",s[i].name,s[i].No); } }
3. Problems encountered in the debugging process of this question and solutions
Error message 1:
No error Reason: No
Correction method: No
https://coding.net/u/aggresiver/p/123/git/blob/master/7.2
7-1 Calculating Employee Wages
1. Design ideas
(1) Mainly describe the topic algorithm
① It is required to write a program to sequentially output the name and actual salary of each employee (actual salary = basic salary + floating salary - expenditure)
②Basic salary, floating salary, and expenditure are all related to a certain employee, so a structure can be defined
③Use the for loop to input the information
④Use the for loop to output sequentially
(2) Flowchart
#include<stdio.h> struct worker { char name[10]; float jb,fd,zc; float fee; }; intmain() { struct worker w[10]; int N,i; scanf("%d",&N); for(i=0;i<N;i++) { scanf("%s %f %f %f",w[i].name,&w[i].jb,&w[i].fd,&w[i].zc); w[i].fee=w[i].jb+w[i].fd-w[i].zc;} for(i=0;i<N;i++){ printf("%s %.2f\n",w[i].name,w[i].fee); } }
3. Problems encountered in the debugging process of this question and solutions
Error message 1:
No error Reason: No
Correction method: No
https://coding.net/u/aggresiver/p/123/git/blob/master/7-10
7-2 Calculate the grade point average
1. Design ideas
(1) Mainly describe the topic algorithm
① Ask to calculate their average grades and output the list of students below the average in order
②Define the structure
③Use the for loop to input the basic information of the students
④Use the for loop again to judge
2. Experimental code
#include<stdio.h> struct student { char No[6]; char name[10]; int sore; }; intmain() { int N,i,sum=0; double avg; struct student s[10]; scanf("%d",&N); for(i=0;i<N;i++) { scanf("%s %s %d",s[i].No ,s[i].name ,&s[i].sore ); sum=sum+s[i].sore ; } avg = sum * 1.0 / N; printf("%.2lf\n",avg); for(i=0;i<N;i++) { if(s[i].sore<avg) printf("%s %s\n",s[i].name,s[i].No); } }
3. Problems encountered in the debugging process of this question and solutions
Error message 1:
No error Reason: No
Correction method: No
https://coding.net/u/aggresiver/p/123/git/blob/master/7.2