- #include <stdio.h>
- #include <string.h>
- typedef struct person
- {
- int age;
- int height;
- char name[15];
- int weight;
- } Person;
- int main()
- {
- Person p[2];
- int i;
- for(i=0; i<2; i++)
- {
- printf("Please input your age:");
- scanf("%d", &p[i].age);
- printf("Please input your height:");
- scanf("%d", &p[i].height);
- printf("Please input your name:");
- scanf("%s", p[i].name);
- printf("Please input your weight:");
- scanf("%d", &p[i].weight);
- }
- printf("--------------------------------------------\\n");
- printf("name\\theight\\tage\\tweight\\n");
- for(i=0;i<2; i++)
- {
- printf("%s\\t%d\\t%d\\t%d\\n", p[i].name, p[i].height, p[i].age, p[i].weight);
- }
- return 0;
- }
- //该片段来自于http://www.codesnippet.cn/detail/0906201512814.html
来源: http://www.codesnippet.cn/detail/0906201512814.html