注:函数名首字母大写,这是规定
调用函数了就传值了,调用了就传值了,调用了就传值了
代码来源于我们的c#老师,因为我实在不晓得该怎么写下去了。
using system;
namespace _0319_某年某月某日
{
class program
{
static void main(string[] args)
{
//控制台输入年月日
console.writeline("请输入年");
int y = convert.toint32(console.readline());
console.writeline("请输入月");
int m = convert.toint32(console.readline());
console.writeline("请输入日");
int d = convert.toint32(console.readline());
console.writeline(y + "年" + m + "月" + d + "日是今年的第" + date(y,m,d)+ "天");//在这里被调用
}
static int date(int y,int m,int d)
{
//定义b装天数
int b = 0;
//数组装天数
int[] array = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
//除2月外还有11个月,所以i=1,i<12
for(int i = 1; i < m; i++)
{
//闰年
if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
{
b = b + array[i];
}
//平年
else
{
array[1] = 28;
b = b + array[i];
}
}
d = d + b;
//返回天数
return d;
}
}
}
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论