50,523
社区成员
发帖
与我相关
我的任务
分享
Scanner sc = new Scanner(System.in);
System.out.println("请输入年月日");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
Calendar cal = Calendar.getInstance();
cal.set(a, b, c);
int d = cal.get(Calendar.DAY_OF_YEAR);
System.out.println(d);
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
while (true) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入年月日");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int s = 0;
int[] monthDays = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
s += c;
for (int i = 0; i < b - 1; i++) {
int days = monthDays[i];
if (i == 1 && (a % 4 == 0 && a % 100 != 0 || a % 400 == 0))
days = 29;
s += days;
}
System.out.println(s);
}
}
}
public class eight {
public static void main(String[] args) {
while(true) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入年月日");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int s = 0;
int m2 = 0;
if (a % 4 == 0 && a % 100 != 0 || a % 400 == 0)
m2 = 29;
else
m2 = 28;
s+=c;
if(b>=2)
s+=31;
if(b>=3)
s+=m2;
if(b>=4)
s+=31;
if(b>=5)
s+=30;
if(b>=6)
s+=31;
if(b>=7)
s+=30;
if(b>=8)
s+=31;
if(b>=9)
s+=31;
if(b>=10)
s+=30;
if(b>=11)
s+=31;
if(b>=12)
s+=30;
System.out.println(s);
}
}
}