标签:ace tput sub 转化 result code main mission 数据格式
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 181543 Accepted Submission(s): 64444
1 #include<string.h> 2 #include<cstdio> 3 #include<stdlib.h> 4 using namespace std; 5 int main() 6 { 7 char s[100]; 8 int time[3]; 9 char * p; 10 11 12 while(scanf("%s",s)!=EOF) 13 { 14 int result = 0; 15 int count = 0; 16 int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; 17 p = strtok(s,"/");//s为要拆分的字符串,必须是char *类型,""里是分隔符,可以" */#"等 18 while(p != NULL)//拆分字符串 19 { 20 time[count++] = atoi(p);//将字符串转化为整型 21 p = strtok(NULL,"/"); 22 } 23 if(time[0]%400 == 0 || ( time[0]%4==0 && time[0]%100!=0 )) 24 { 25 month[2] = 29; 26 } 27 for(int i = 1;i < time[1];++i) 28 { 29 result += month[i]; 30 } 31 result += time[2]; 32 printf("%d\n",result); 33 34 } 35 return 0; 36 }
标签:ace tput sub 转化 result code main mission 数据格式
原文地址:https://www.cnblogs.com/knmxx/p/9288550.html