12.1
#include<stdio.h>
#define NAME_LEN 64
struct student{
char name[NAME_LEN];
int height;
float weight;
long schols;
};
int main(void)
{
struct student takao = {
"Takao", 173, 86.2};
printf("姓名 = %s\n", takao.name);
printf("身高 = %d\n", takao.height);
printf("体重 = %.1f\n", takao.weight);
printf("奖学金 = %ld\n", takao.schols);
printf("姓名的地址为%p\n", &takao.name);
printf("身高的地址为%p\n", &takao.height);
printf("体重的地址为%p\n", &takao.weight);
printf("奖学金的地址为%p\n", &takao.schols);
return 0;
}
12.2
#include<stdio.h>
#define NAME_LEN 64
struct student
{
char name[NAME_LEN];
int height;
float weight;
long schols;
};
void hiroko(struct student *std)
{
if (std->height < 180)
std->height = 180;
if (std->weight > 80)
std->weight = 80;
}
int main(void)
{
struct student sanako;
printf("姓名: "); scanf("%s", sanako.name);
printf("身高: "); scanf("%d", &sanako.height);
printf("体重: ");