C中有关return的问题
函数调用中return 是否只能返回一个值,
若要返回多个值应该怎么做?
程序代码:#include <stdio.h>
int daynum[2][13] = { {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
int day_of_year (int year, int month, int day) /* 将输入的年月日转换成输入日是输入年的若干天*/
{
int leap = year % 4 == 0 && year % 100 != 0 || year % 400 ==0, i = 1;
while (i < month) day += daynum[leap][i], ++ i;
return day;
}此例全局变量没有改变值,如果你通过某种方式改变了全局变量,那么现在全局变量的值就是你刚修改过的值
