微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c语言 12-2

1、

#include <st@R_404[email protected]>

#define NAME_LEN 64

typedef struct student{
    char name[NAME_LEN];
    int height;
    float weight;
    long schols;
}Student;

void judg(Student *x)
{
    if(x -> height < 180)
        x -> height = 180;
    if(x -> weight > 80)
        x -> weight = 80;    
}  

int main(void)
{
    Student sanata;    
    printf("sanata.name:  "); scanf("%s", sanata.name);
    printf("sanata.height:  "); scanf("%d", &sanata.height);
    printf("sanata.weight:  "); scanf("%f", &sanata.weight);
    printf("sanata.schols:  "); scanf("%ld", &sanata.schols);
    
    judg(&sanata);
    puts("\n==================================\n");
    
    printf("sanata.name:  %s\n", sanata.name);
    printf("sanata.height:  %d\n", sanata.height);
    printf("sanata.weight:  %.2f\n", sanata.weight);
    printf("santa.schols:  %ld\n", sanata.schols);
    
    return 0;
}

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐