10.11.1-PointersOnC-20220308

#include<stdio.h>
typedef struct{
	unsigned short area;
	unsigned short exchange;
	unsigned short station;
}Number;
typedef struct{
	unsigned char year;
	unsigned char month;
	unsigned char day;
	unsigned char hour;
	unsigned char minute;
	unsigned char second;
}Time;
typedef struct{
	Time time;
	Number number_calling;
	Number number_called;
	Number number_billed;
}Addresslist;
void timeinput(Addresslist *addresslist);
void numberinput(Addresslist *addresslist);
int main(){
	Addresslist addresslist={0};
	timeinput(&addresslist);
	numberinput(&addresslist);
	printf("The addresslist:\nYear:%d%d Month:%d Day:%d\nCallingNumber:%d-%d-%d\nCalledNumber:%d-%d-%d\nBilledNumber:%d-%d-%d\n",
		addresslist.time.year>99?2:20,addresslist.time.year,addresslist.time.month,addresslist.time.day,
		addresslist.number_calling.area,addresslist.number_calling.exchange,addresslist.number_calling.station,
		addresslist.number_called.area,addresslist.number_called.exchange,addresslist.number_called.station,
		addresslist.number_billed.area,addresslist.number_billed.exchange,addresslist.number_billed.station);
return 0;}
//
void timeinput(Addresslist *addresslist){
	unsigned int ch=0,temp_year=0,temp_month=0,temp_day=0;
	for(fputs("Input the year,month,day,divided with space:->",stdout);
		(ch=scanf_s("%u %u %u",&temp_year,&temp_month,&temp_day))!=3||temp_year>2256||temp_year<2000||temp_month>12||temp_day>31;
		fputs("Input the year month day,divided with space:->",stdout));
	while((ch=getchar())!=EOF&&ch!=10);
	temp_year%=1000;
	addresslist->time.year=temp_year,addresslist->time.month=temp_month,addresslist->time.day=temp_day;
}

void numberinput(Addresslist *addresslist){
	unsigned int ch=0,temp_area=0,temp_exchange=0,temp_station=0;
	for(fputs("Input the area,exchange,station of calling number,divides with space:->",stdout);
		(ch=scanf_s("%u %u %u",&temp_area,&temp_exchange,&temp_station))!=3;
		fputs("Input the area,exchange,station of calling number,divides with space:->",stdout));
	while((ch=getchar())!=EOF&&ch!=10);
	addresslist->number_calling.area=temp_area;
	addresslist->number_calling.exchange=temp_exchange;
	addresslist->number_calling.station=temp_station;
	for(fputs("Input the area,exchange,station of called number,divides with space:->",stdout);
		(ch=scanf_s("%u %u %u",&temp_area,&temp_exchange,&temp_station))!=3;
		fputs("Input the area,exchange,station of called number,divides with space:->",stdout));
	while((ch=getchar())!=EOF&&ch!=10);
	addresslist->number_called.area=temp_area;
	addresslist->number_called.exchange=temp_exchange;
	addresslist->number_called.station=temp_station;
	for(fputs("Input the area,exchange,station of billed number,divides with space:->",stdout);
		(ch=scanf_s("%u %u %u",&temp_area,&temp_exchange,&temp_station))!=3;
		fputs("Input the area,exchange,station of billed number,divides with space:->",stdout));
	while((ch=getchar())!=EOF&&ch!=10);
	addresslist->number_billed.area=temp_area;
	addresslist->number_billed.exchange=temp_exchange;
	addresslist->number_billed.station=temp_station;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fleet1126

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值