c语言 12-2

1、

#include <stdio.h>

#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("
==================================
");
    
    printf("sanata.name:  %s
", sanata.name);
    printf("sanata.height:  %d
", sanata.height);
    printf("sanata.weight:  %.2f
", sanata.weight);
    printf("santa.schols:  %ld
", sanata.schols);
    
    return 0;
}

原文地址:https://www.cnblogs.com/liujiaxin2018/p/14852408.html