7-1 Calculate employee wages
1. Design ideas
(1) Understand the meaning of the question and clarify the idea.
(2) Edit the algorithm as required.
(3) Run the program and check for errors.
2. Flowchart
without
3 Experimental code
#include<stdio.h>
int main()
{
int n,i;
scanf("%d",&n);
struct cj
{
char name[10];
float x,y,z;
}lcj[1000];
for(i=0;i<n;i++)
scanf("%s%f%f%f",&lcj[i].name,&lcj[i].x,&lcj[i].y,&lcj[i].z);
for(i=0;i<n;i++)
printf("%s %.2lf\n",lcj[i].name,lcj[i].x+lcj[i].y-lcj[i].z);
}
4. Error reason
No
git address: https://git.coding.net/wczwcz/6.1.git
7-2 Calculate the average score
1. Design ideas
(1) Understand the meaning of the question and clarify the idea.
(2) Edit the algorithm as required.
(3) Run the program and check for errors.
2. Flowchart
without
3 Experimental code
#include<stdio.h>
int main()
{int i,n;
float z=0;
scanf("%d",&n);
struct stu
{
char name[10];
float x;
char y[10];
}stu1[1000];
for(i=0;i<n;i++)
{scanf("%s%s%f",&stu1[i].y,&stu1[i].name,&stu1[i].x);
z=z+stu1[i].x;}
z=z/n*1.0;
printf("%.2f\n",z);
for(i=0;i<n;i++)
if(stu1[i].x<z)
printf("%s %s\n",stu1[i].name,stu1[i].y);
}
4. Cause of error
No
git address: https://git.coding.net/wczwcz/6.1.git