题解 | #学生基本信息输入输出#

学生基本信息输入输出

https://www.nowcoder.com/practice/58b6a69b4bf943b49d2cd3c15770b9fd

有无用数组实现的?

#include <stdio.h>

struct Subject 
{
    int number;
    float score1 , score2 , score3; 
};

int main() 
{
    struct Subject s = {0, 0, 0, 0}; // 定义结构体变量并初始化
    scanf("%d;%f,%f,%f", &s.number, &s.score1, &s.score2, &s.score3); // 输入结构体成员的值
    printf("The each subject score of No. %d is %.2f, %.2f, %.2f.\n", s.number, s.score1, s.score2, s.score3); // 输出结构体成员的值
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务