1 条题解
-
0
C :
#include <stdio.h> struct person { int num; char name[10]; char sex; char job; union { int class; char position[10]; }category; }person[100]; int main() { int n, i; scanf("%d", &n); for (i = 0;i < n;i++) { scanf("%d %s %c %c", &person[i].num, person[i].name, &person[i].sex, &person[i].job); if (person[i].job == 's') { scanf("%d", &person[i].category.class); } else { scanf("%s", person[i].category.position); } } for (i = 0;i < n;i++) { 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.class); else printf("%s\n", person[i].category.position); } return 0; }
C++ :
#include <stdio.h> int main () { struct hero { int cla; char position[10]; } c; typedef struct { int num; char name[10]; char sex; char job; struct hero c; } student; student a; int n; scanf("%d",&n); while (n--) { scanf("%d%s %c %c ",&a.num,a.name,&a.sex,&a.job); if ('s'==a.job) { scanf("%d",&a.c.cla); printf("%d %s %c %c %d\n",a.num,a.name,a.sex,a.job,a.c.cla); } else { scanf("%s",a.c.position); printf("%d %s %c %c %s\n",a.num,a.name,a.sex,a.job,a.c.position); } } return 0; }
Pascal :
var i,n:longint; m:string; begin readln(n); for i:=1 to n do begin readln(m); writeln(m); end; end.
- 1
信息
- ID
- 1381
- 时间
- 1000ms
- 内存
- 32MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者