C-study/09-1/2/2.c

32 lines
690 B
C
Raw Normal View History

#include<stdio.h>
#include<string.h>
union Categ{
int clas;
char position[10];
};
struct{
int num;
char name[10];
char sex;
char job;
union Categ category;
}person[2];
int main(){
for(int i=0;i<2;i++){
scanf("%d\n%s\n%c\n%c",&person[i].num,person[i].name,&person[i].sex,&person[i].job);
if(person[i].job=='s')
scanf("%d",&person[i].category.clas);
else
scanf("%s",person[i].category.position);
printf("%d %s %c %c",person[i].num,person[i].name,person[i].sex,person[i].job);
if(person[i].job=='s')
printf(" %d\n",person[i].category.clas);
else
printf(" %s\n",person[i].category.position);
}
return 0;
}