a^b转为迭代计算
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); int b = scanner.nextInt(); String []week = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; int today = 0; int day = 1; for(int i = 0; i < b; i++) day = (day * a) % 7; System.out.print(week[(today + day) % 7]); } }
0.0分
5 人评分
简单的a+b (C语言代码)浏览:752 |
WU-蓝桥杯算法提高VIP-勾股数 (C++代码)浏览:1685 |
剪刀石头布 (C语言代码)浏览:1792 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:561 |
时间转换 (C语言代码)浏览:697 |
企业奖金发放 (C语言代码)浏览:2459 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:607 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:504 |
小O的乘积 (C++代码)浏览:545 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:518 |