文章
2
粉丝
0
获赞
3
访问
188
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
string S;
while(cin>>S){
string a,b,c;
int y,m,d,sum=0;
int aa[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
a=S.substr(0,4);
b=S.substr(5,2);
c=S.substr(8,2);
y=stoi(a);
m=stoi(b);
d=stoi(c);
if((y%100!=0&&y%4==0)||y%400==0){
aa[2]=29;
}
for(int i=0;i<m;i++){
&nbs...
登录后发布评论
不要这样输入字符串来解析,因为年月日的格式不一定,比如2026 9 20和2026 12 2
用下面这种方法分别输入年月日就可以
while (cin >> y >> m >> d)