markdown 在线制作ppt json校验和格式化工具

POJ 2080

import java.util.*;
public class Main {
    
        
            public static void main(String args[]){
                   Scanner cin=new Scanner(System.in);
                   int num;
                   while(true){
                   num=cin.nextInt();
                   if(num==-1)
                       break;
                   num_year(num);
                   num_last(num);
                   }
                }
            public static boolean judge_leap(int num){
               return (num%4==0&&num%100!=0)||(num%400==0);
             } 
            public static void num_year(int num){
               int one_year=0;
               int sum=0;
               int year=2000;
               while(sum<=num){
                
                one_year=365;
                if(judge_leap(year))
                    one_year++;
                sum+=one_year;
                year++;
               }
               num-=(sum-one_year);
               System.out.print(year-1);
               num_month(num,year-1);
               
            }
            public static void num_month(int num,int year){
                int[] month=new int[]{0,31,28,31,30,31,30,31,31,30,31,30,31};
                int sum=0;
                int i=1;
                while(sum<=num){
                    if(judge_leap(year)&&i==2)
                        month[i]++;
                    sum+=month[i];
                    i++;
                    
                }
                num-=(sum-month[i-1]);
                System.out.print("-");
                if(i-1<10)
                    System.out.print(0);
                System.out.print(i-1);
                num_day(num);
            }
            public static void num_day(int num){
                System.out.print("-");
                if(num+1<10)
                    System.out.print(0);
                System.out.print(num+1+" ");
                
                
            }
            public static void num_last(int num){
                num+=6;
                num=num%7;
                switch(num){
                case 1:System.out.println("Monday");break;
                case 2:System.out.println("Tuesday");break;
                case 3:System.out.println("Wednesday");break;
                case 4:System.out.println("Thursday");break;
                case 5:System.out.println("Friday");break;
                case 6:System.out.println("Saturday");break;
                case 0:System.out.println("Sunday");break;
                }
            }
    }

 

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。 

技术网站地址: vmfor.com

posted @ 2015-06-10 17:01  GavinHacker  阅读(276)  评论(0编辑  收藏  举报
markdown 在线制作ppt json校验和格式化工具