直接用结构体变量就行的。
没学过只能一岩橘个一个去定义了
#include <stdio.h>
typedef struct
{
char name[10]
int age
char sex[6]
int height
}people
int main() {
people a
scanf("%s %d %s %d",a.name,&a.age,a.sex,&a.height)
printf("您输粗绝团入的信息为:\n")
printf("%s %d %s %d\n",a.name,a.age,a.sex,a.height)
}
#include <stdio.h>#include "stdlib.h"
#include "string.h"
typedef struct Person{
char *name
int age
float height
void show()
{
printf("name is %s,age 枣郑is %d,height is %.2f\n",name,age,height)
}
}Person
int main()
{
Person mp[20]
int i
for (i=0i<20i++)
{
mp[i].name=(char *)malloc(sizeof("档岩漏张三丰")+1)
strcpy(mp[i].name,"张三丰")
mp[i].age=147
mp[i].height=185.44
}
for 行烂(i=0i<20i++)
{
mp[i].show()
}
return 0
}
#include <stdio.h>void main()
{
char sex
int f,m
printf("测量人的性别(m/f):")
scanf("%c",&sex)
switch(sex)
{
case 'm':printf("%g",(1.7+1.6)*1.08/2)break
case 'f':printf("%g",(1.7+1.6*0.923)/2)break
default:printf("输入错误!")
}
return
}
/档尘薯兄举/纯手打,望行者采纳,有问题追问
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)