- class GetMoneyOfDay
- {
- public static void main(String [] args){
- int i=1,j = 1,sum = 0;
- while(sum<100){
- if(i < 7*j){
- sum = sum+10;
- System.out.println("第"+i+"天"+"存"+sum+"元");
- i++;
- }else if(i==7*j){
- sum = (sum+20)/2;
- System.out.println("第"+i+"天"+"存"+sum+"元");
- i++;
- j++;
- }
-
- }
- System.out.println("总共需要"+(i-1)+"天");
- }
- }
复制代码 |