我有一个具有以下结构的地图数据结构: - "英国的首都" - >"伦敦""法国的首都" - >"巴黎"我想循环显示这个问题的地图: "英国的首都是什么",要求用户输入.如果用户回答"伦敦",我打印正确,否则,我打印正确答案"伦敦".这在像C#这样的命令式语言中很容易,但我还没想到如何在Haskell中做到这一点.
import java.time.LocalDate;
import java.time.Period;
public class DateDiff {
public static void main(String[] args) {
/** The date at the end of the last century */
LocalDate endofCentury = LocalDate.of(2000, 12, 31);
LocalDate now = LocalDate.now();
Period diff = Period.between(endofCentury, now);
System.out.printf("The 21st century (up to %s) is %s old%n", now, diff);
System.out.printf("The 21st century is %d years, %d months and %d days old",
diff.getYears(), diff.getMonths(), diff.getDays());
}
}
Run Code Online (Sandbox Code Playgroud)
没有找到本地日期我错过了一个import指令