正在加载图片...
通过指针实现函数调用返回多个值例8-4输入年和天数,输出对应的年、月、日。例如:输入2000和61,输出2000-3-1。定义函数month_day(year,yearday,*pmonth,*pday)用2个指针作为函数的参数,带回2个结果int main (void)intday,month,year,yearday;void month_day(int year,int yearday, int*pmonth,int*pday);printf("input year and yearday:");scanf ("%d%d", &year, &yearday);month_day (year, yearday, &month, &day);printf ("%d-%d-%d In", year, month, day );return ;1通过指针实现函数调用返回多个值 例8-4 输入年和天数,输出对应的年、月、日。 例如:输入2000和61,输出2000-3-1。 定义函数month_day(year, yearday,*pmonth,*pday) 用2个指针作为函数的参数,带回2个结果 int main (void) { int day, month, year, yearday; void month_day(int year,int yearday, int *pmonth,int *pday); printf(“input year and yearday: ”); scanf ("%d%d", &year, &yearday ); month_day (year, yearday, &month, &day ); printf ("%d-%d-%d \n", year, month, day ); return 0; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有