【简单到死系列】人事系统

  • Post author:
  • Post category:其他


输出表格弄得不太对

#include<stdio.h>

int main()
{
	struct birthday
	{
		int year;
	    int month;
	    int day;
	};
    struct persons
	{
		long int num;
	    char name[20];
	    char gender[5];
	    struct birthday birth;
     	int phone[10];
	} person[2];

	for(int i=0;i<=1;i++)//大循环,可以连续输入
	{
	    printf("num:");
		scanf("%ld",&person[i].num);
		printf("name:");
		scanf("%s",&person[i].name);//可以将数组数据转换成字符串数据,*name[20]*改为name
		printf("gender:");
		scanf("%s",&person[i].gender);
        printf("birthday:");
		scanf("%d,%d,%d",&person[i].birth.year,&person[i].birth.month,&person[i].birth.day);
		printf("phone:");
		scanf("%s",&person[i].phone);//整型数组也可以强制转换为字符串数据
		printf("\n");
	}
	
	printf("\t__________________________________________________________\n");
	printf("\t| num |    name    | gender |   birthday   |    phone    |\n");
	printf("\t__________________________________________________________\n");
	printf("\t|  %d |%s |%s | %d | %d | %d |%s          |\n",person[0].num,person[0].name,person[0].gender,person[0].birth.year,person[0].birth.month,person[0].birth.day,person[0].phone);
	printf("\t__________________________________________________________\n");
	printf("\t|  %d |%s |%s | %d | %d | %d |%s          |\n",person[1].num,person[1].name,person[1].gender,person[1].birth.year,person[1].birth.month,person[1].birth.day,person[1].phone);
	printf("\t__________________________________________________________\n");
	return 0;
}



版权声明:本文为hawazaki原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。