From Crescent School
About
import java.util.Scanner;
public class CCCJ1_Calendar {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int start = in.nextInt();
int days = in.nextInt();
int spaces;
System.out.println("Sun Mon Tue Wed Thr Fri Sat");
spaces = start*4-3;
while(spaces > 0){
System.out.print(" ");
spaces--;
}
for(int i = 0, x = start; i < days; i++){
boolean first = false;
if(x == 7)
first = true;
if(i < 9)
System.out.print(" " + (i+1));
else
System.out.print((i+1));
if(x < 7){
System.out.print(" ");
x++;
}
if (x == 7 && first){
System.out.print("\n ");
x = 1;
}
else if(x == 7) {
i++;
if(i < 9)
System.out.print(" " + (i+1) + "\n ");
else
System.out.print((i+1) + "\n ");
x = 1;
}
}
}
}