何处生筱笙 2021-06-03 10:45 采纳率: 66.7%
浏览 50
已采纳

自学的c语言看见一道题,有没有大佬给说一下呀

 

  • 写回答

4条回答 默认 最新

  • 关注
    
    #include "stdio.h"
    
    #define N 2
    struct Student
    {
    	//学号
    	int		num; //成员变量或者一个数据项
    	//姓名
    	char	name[20];
    	//性别
    	char	sex; //M,F
    	//成绩
    	float	html;	
    	float	ppt;
    	float	cyuyan;
    	float	sum;
    }st[N];
    void input();
    void display();
    void main()
    {
        input();
        display();
    }
    //输入函数
    void input()
    {
    	int i;
    	for(i=0;i<N;i++)
    	{
    		printf("请输入第%d个学生的学号,姓名,性别,html,ppt,cyuyan:",i+1);
    		scanf("%d",&st[i].num);
    		scanf("%s ",st[i].name);
    		scanf("%c ",&st[i].sex);
    		scanf("%f",&st[i].html);
    		scanf("%f",&st[i].ppt);
    		scanf("%f",&st[i].cyuyan);
    		st[i].sum = st[i].html+st[i].ppt+st[i].cyuyan;
    	}
    		
    }
    //输出
    void display()
    {
    	int i;
    	printf("学号\t姓名\t\t性别\thtml\tppt\tC语言\t总分\t平均分\n");	
    	for(i=0;i<N;i++)
    	{
    		printf("%d\t%s\t%c\t%0.2f\t%0.2f\t%0.2f\t%0.2f\t%0.2f\n",st[i].num,st[i].name,st[i].sex,st[i].html,st[i].ppt,st[i].cyuyan,st[i].sum,st[i].sum/3);
    	}	
    }
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料