美文网首页
acmtest1.j

acmtest1.j

作者: wolfway_d0ff | 来源:发表于2018-12-09 22:29 被阅读0次

运用数组来解决数据叠加问题,以月为条件,来依次增加天数,用if语句来判断年份是否为闰年,若为闰年则2月为29天,在输入/时,加入char型来输入。
...

include<iostream>

using namespace std;
int main()
{
int n, m, r;
char z, c;
while (cin >> n>>z >> m >>c>> r)
{
int a[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
if (n % 400 == 0 || (n % 4 == 0 && n % 100 != 0))
{
a[1] = 29;
}
int i = 0;
int x = 0;
while (i < m - 1)
{
x = x + a[i];
i++;
}
int y;
y = x + r;
cout << y << endl;
}
return 0;
}
...

相关文章

  • acmtest1.j

    运用数组来解决数据叠加问题,以月为条件,来依次增加天数,用if语句来判断年份是否为闰年,若为闰年则2月为29天,在...

网友评论

      本文标题:acmtest1.j

      本文链接:https://www.haomeiwen.com/subject/hvclhqtx.html