HDU 2005 the first day? (Java)

Source: Internet
Author: User

Problem:

Java input is too troublesome, ask the big God pointing!!!

Here you can use it as a format input:

Scanner cin=new Scanner (system.in);
int y,m,d;
String s;
String Yy,mm,dd;
while (Cin.hasnext ()) {
Yy=mm=dd= "";
S=cin.next ();
Char[] Ss=s.tochararray ();
int j = 0;
for (int i=0;i<ss.length;i++)
{
if (ss[i]== '/')
{
J=i;
Break
}
Yy+=ss[i];
}
for (int i=j+1;i<ss.length;i++)
{
if (ss[i]== '/')
{
J=i;
Break
}
Mm+=ss[i];
}
for (int i=j+1;i<ss.length;i++)
{
Dd+=ss[i];
}
Char[] Yyy=yy.tochararray ();
Char[] Mmm=mm.tochararray ();
Char[] Ddd=dd.tochararray ();
int len=yyy.length;
int yyyy=0;
for (int i=0;i<yyy.length;i++)
{
int tem = yyy[i]-' 0 ';
for (int j1=1;j1<len;j1++)
tem*=10;
Yyyy+=tem;
len--;
}
int dddd=0;
Len=ddd.length;
for (int i=0;i<ddd.length;i++)
{
int tem = ddd[i]-' 0 ';
for (int j1=1;j1<len;j1++)
tem*=10;
Dddd+=tem;
len--;
}
int mmmm=0;
Len=mmm.length;
for (int i=0;i<mmm.length;i++)
{
int tem = mmm[i]-' 0 ';
for (int j1=1;j1<len;j1++)
tem*=10;
Mmmm+=tem;
len--;



The first day?Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 92951 Accepted Submission (s): 35005


Problem description Given a date, the output date is the day ordinal of the year.
Input data has multiple groups, each group of one row, the data format is YYYY/MM/DD composition, see sample input, in addition, you can ensure that all input data is legitimate.
Output for each set of input data, outputs one row, indicating that the date is the day ordinal of the year.
Sample Input
1985/1/202006/3/12

Sample Output
2071
Code:

Import java.util.*;p ublic class main{public static void Main (String args[]) {Scanner cin=new Scanner (system.in); int y,m,d ; String s; String Yy,mm,dd;while (Cin.hasnext ()) {yy=mm=dd= ""; S=cin.next (); char[] Ss=s.tochararray (); int j = 0;for (int i=0;i< ss.length;i++) {if (ss[i]== '/') {j=i;break;} Yy+=ss[i];} for (int i=j+1;i<ss.length;i++) {if (ss[i]== '/') {j=i;break;} Mm+=ss[i];} for (int i=j+1;i<ss.length;i++) {dd+=ss[i];} Char[] Yyy=yy.tochararray (); char[] Mmm=mm.tochararray (); char[] Ddd=dd.tochararray (); int len=yyy.length;int yyyy=0; for (int i=0;i<yyy.length;i++) {int tem = yyy[i]-' 0 ', for (int j1=1;j1<len;j1++) tem*=10;yyyy+=tem;len--;} int dddd=0;len=ddd.length;for (int i=0;i<ddd.length;i++) {int tem = ddd[i]-' 0 '; for (int j1=1;j1<len;j1++) tem*=10; dddd+=tem;len--;} int mmmm=0;len=mmm.length;for (int i=0;i<mmm.length;i++) {int tem = mmm[i]-' 0 '; for (int j1=1;j1<len;j1++) tem*=10; mmmm+=tem;len--;} Y=yyyy;m=mmmm;d=dddd;int sum=0;int a[]={31,28,31,30,31,30,31,31,30,31,30,31};for (int i=0;i<m-1;i++) Sum+=a[i];sum=sum+d;int t=0;if ((y%400) ==0| | y%4==0&&y%100!=0) t=1;if (t==1&&m>2) sum=sum+1; SYSTEM.OUT.PRINTLN (sum);}}}


HDU 2005 the first day? (Java)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.