第三次作业

一、学习内容总结

2 课上疑点:讨论查阅分析 struct sk{int a; char str)}p; p->str++ 中的++ 加向________?
答:加向str。

二.pta

题目1查找书籍中最高价及最低价

1.设计思路

  • 定义结构体book,并且对成员分量名字name价格price进行定义。
  • 输入n表示有n本书,利用循环输入书名和价格。
  • 定义最大值与最小值。
  • 在循环体中将每本书的价格与最大价格max.price和最小价格min.price比较,如果价格大于max.price就将p.price传给max.price,如果价格小于min就将p.price传给min.price。
  • 输出结果。
    2.流程图
    第三次作业_第1张图片
    3.代码

#include   
#include   
#include   
#include   
  
int main()  
{  
    struct bookandprice  
    {  
        char name[300];  
        double price;   
    }now,max,min;  
  
    max.price=0;  
    min.price=999999999999999999;  
    int n,i;  
    scanf("%d",&n);  
    for(i=1;i<=n;i++)  
    {  
        getchar();  
        gets(now.name);  
        scanf("%lf",&now.price);  
        if(now.price>max.price)  
        {  
            strcpy(max.name,now.name);  
            max.price=now.price;  
        }  
        if(now.price

题目2 计算平均成绩

1.设计思路

  • 填写基本结构,基础函数。
  • 对平均数赋初值,并输入人的个数以及对应的学号,姓名,成绩,并把每一个学生的成绩累加。
  • 利用循环结构相加。
  • 输出结果
    2.流程图
    第三次作业_第2张图片
    3.代码
#include
#include
#include
struct student{
    char num[20];
    char name[20];
    int score;
        
}s[1000],*p;
int main(){
    int N;
    int i=0,count;
    scanf("%d",&N);
    for(i=0;i

要求三、学习总结和进度(20分)

1、指针与结构作业中题目所使用的知识点
1、指针与结构作业中题目所使用的知识点。
1.结构体的正确使用和输出定义的变量。
2.使用指针可以代替类似&s[i]的输入,在用到p->时,有明确的分层指向时,不必要写出两个界限,就如结构二中的题目一样。

git

你可能感兴趣的:(第三次作业)