pta第三次作业

题目 7-1 计算职工工资
1.设计思路
(1)第一步:观察题意了解各个参数与所需函数在题目中的意义;
第二步:设计算法编写函数,让函数的功能实现题目中所需的功能;
第三步:运行程序检测是否错误。
(2)流程图

2.实验代码

#include <stdio.h>
struct student {
 char name[10];
 double c1;
 double c2;
 double c3;
}s[100000];
int main(int argc, char *argv[])
{
 int n;
 double  sal;
 scanf("%d",&n);
 for(int i=0;i<n;i++){
  scanf("%s %lf %lf %lf",&s[i].name,&s[i].c1,&s[i].c2,&s[i].c3);
  sal=s[i].c1+s[i].c2-s[i].c3;
  printf ("%s %.2lf\n",s[i].name,sal);  

 }
 
 return 0;
}

3.本题调试过程碰到问题及解决办法
错误信息1:无
错误原因:无
改正方法:无
git地址 https://git.coding.net/hxc980203/566.git

题目7-2 计算平均成绩
1.设计思路
(1)第一步:观察题意了解各个参数与所需函数在题目中的意义;
第二步:设计算法编写函数,让函数的功能实现题目中所需的功能;
第三步:运行程序检测是否错误。
(2)流程图

2.实验代码

#include<stdio.h>
struct student
{
    char id[6];
    char name[10];
    int score;
};
int main()
{
    int n;
    int i;
    float avg=0;
    struct student s[10];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s%s%d",s[i].id,s[i].name,&s[i].score);
        avg=avg+s[i].score;
    }
    avg=avg/n;
    printf("%.2f\n",avg);
    for(i=0;i<n;i++)
    {
        if(s[i].score<avg)
        {
            printf("%s %s\n",s[i].name,s[i].id);
        }
    }
}

3.本题调试过程碰到问题及解决办法
错误信息1:无
错误原因:无
改正方法:无
git地址 https://git.coding.net/hxc980203/123.git

posted @ 2018-04-21 10:57  黄学超  阅读(130)  评论(0编辑  收藏  举报