• 编译器进行语法分析


    首先编译器进行语法分析,也就是要把那些字符串分离出来。

    然后进行语义分析,就是把各个由语法分析分析出的语法单元的意义搞清楚。

    最后生成的是目标文件,也称为obj文件。

    再经过链接器的链接就可以生成最后的EXE文件了。

    有些时候需要把多个文件产生的目标文件进行链接,产生最后的代码。这一过程称为交叉链接。

     

      1 package Com.Table;
      2 import java.util.Scanner;
      3 public class EightTable {
      4     static String CaculateWeekDay(int y,int m,int d)
      5     {
      6         if(m==1)
      7         {
      8             m = 13;
      9             y--;
     10         }
     11         if(m==2)
     12         {
     13             m=14;
     14             y--;
     15         }
     16         int week=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;
     17         String weeks = null;
     18         switch(week)
     19         {
     20             case 0: weeks="Monday"; break;
     21             case 1: weeks="Tuesday"; break;
     22             case 2: weeks="Wednesday"; break;
     23             case 3: weeks="Thursday"; break;
     24             case 4: weeks="Friday"; break;
     25             case 5: weeks="Saturday "; break;
     26             case 6: weeks="Sunday"; break;
     27         }
     28         return weeks;
     29     }
     30  
     31     public static void main(String [] args)
     32     {
     33         int [][] day = new int[5][7];
     34         System.out.print("input year:");
     35         Scanner scanner = new Scanner(System.in);
     36         int Year = scanner.nextInt();
     37         System.out.print("input mounths:");
     38         int Mounth = scanner.nextInt();
     39  
     40         System.out.println("Sunday 	 Monday 	 Tuesday 	 Wednesday 	 Thursday 	 Friday 	 Saturday");
     41         int flag = 0;
     42         String Week = CaculateWeekDay(Year, Mounth, 1);
     43         if (Week.equals("Monday"))
     44         {
     45             day[0][1] = 1;
     46         }
     47         if (Week.equals("Tuesday"))
     48         {
     49             day[0][2] = 1;
     50         }
     51         if (Week.equals("Wednesday"))
     52         {
     53             day[0][3] = 1;
     54         }
     55         if (Week.equals("Thursday"))
     56         {
     57             day[0][4] = 1;
     58         }
     59         if (Week.equals("Friday"))
     60         {
     61             day[0][5] = 1;
     62         }
     63         if (Week.equals("Saturday"))
     64         {
     65             day[0][6] = 1;
     66             flag = 1;
     67         }
     68         if (Week.equals("Sunday"))
     69         {
     70             day[0][0] = 1;
     71         }
     72  
     73         if (Mounth == 1 ||
     74                 Mounth == 3 ||
     75                 Mounth == 5 ||
     76                 Mounth == 7 ||
     77                 Mounth == 8 ||
     78                 Mounth == 10 ||
     79                 Mounth == 12)
     80         {
     81             for (int i = 0; i < 5; i++)
     82             {
     83                 for (int j = 0; j < 7; j++)
     84                 {
     85                     if (day[i][j] == 1)
     86                     {
     87                         for (int m = 0; m < 31; m++)
     88                         {
     89                             System.out.print(day[i][j] + m + "		");
     90                             if ((j + m + 1) % 7 == 0)
     91                             {
     92                                 System.out.println();
     93                             }
     94                         }
     95                     }
     96                     else
     97                     {
     98                         System.out.print("		");
     99                     }
    100                 }
    101  
    102             }
    103         }
    104         else if (Mounth == 4 ||
    105                 Mounth == 6 ||
    106                 Mounth == 9 ||
    107                 Mounth == 11)
    108         {
    109             for (int i = 0; i < 5; i++)
    110             {
    111                 for (int j = 0; j < 7; j++)
    112                 {
    113                     if (day[i][j] == 1)
    114                     {
    115                         for (int m = 0; m < 30; m++)
    116                         {
    117                             System.out.print(day[i][j] + m + "		");
    118                             if ((j + m + 1) % 7 == 0)
    119                             {
    120                                 System.out.println();
    121                             }
    122                         }
    123                     }
    124                     else
    125                     {
    126                         System.out.print("		");
    127                     }
    128                 }
    129  
    130             }
    131         }
    132         else
    133         {
    134             if ((Year % 4 == 0 || Year % 400 == 0) && Year % 100 != 0)
    135             {
    136                 for (int i = 0; i < 5; i++)
    137                 {
    138                     for (int j = 0; j < 7; j++)
    139                     {
    140                         if (day[i][j] == 1)
    141                         {
    142                             for (int m = 0; m < 29; m++)
    143                             {
    144                                 System.out.print(day[i][j] + m + "		");
    145                                 if ((j + m + 1) % 7 == 0)
    146                                 {
    147                                     System.out.println();
    148                                 }
    149                             }
    150                         }
    151                         else
    152                         {
    153                             System.out.print("		");
    154                         }
    155                     }
    156                 }
    157             }
    158             else
    159             {
    160                 for (int i = 0; i < 5; i++)
    161                 {
    162                     for (int j = 0; j < 7; j++)
    163                     {
    164                         if (day[i][j] == 1)
    165                         {
    166                             for (int m = 0; m < 28; m++)
    167                             {
    168                                 System.out.print(day[i][j] + m + "		");
    169                                 if ((j + m + 1) % 7 == 0)
    170                                 {
    171                                     System.out.println();
    172                                 }
    173                             }
    174                         }
    175                         else
    176                         {
    177                             System.out.print("		");
    178                         }
    179                     }
    180  
    181                 }
    182             }
    183         }
    184     }
    185 }
  • 相关阅读:
    天才绅士少女助手克里斯蒂娜「推柿子」
    sum「莫队」
    simple,跳楼机,[同余系最短路]
    ceoi「chase」
    jzoj5195 数的划分
    lcis
    rectangle
    w
    v·y「状压dp」
    分手是住院「期望dp」
  • 原文地址:https://www.cnblogs.com/borter/p/9384230.html
Copyright © 2020-2023  润新知