• 第六次作业


    1. 打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。(知识点:循环语句、条件语句)
    2.
    在控制台输出以下图形(知识点:循环语句、条件语句)
    
    
    
    3. 输入年月日,判断这是这一年中的第几天(知识点:循环语句、条件语句)
    4.由控制台输入一个4位整数,求将该数反转以后的数,如原数为1234,反转后的数位4321(知识点:循环语句、条件语句)
    1.package com.itheima08;
    public class HelloBudget {
    public static void main(String[] args ){
    int i=100;
    for(;i<1000;i++){
        int ge=i%10;
        int shi=i/10%10;
        int bai=i/100%10;
        if(i==(ge*ge*ge+shi*shi*shi+bai*bai*bai)){
            System.out.println(i);
    }
    }
    }
    }
    2.1
    package com.itheima08;
    import java.util.*;
    public class HelloBudget {
    public static void main(String[] args ){
         for(int i = 1; i <= 6; i++)
         {
             for(int j = 0; j < i; j++)
             {
                 System.out.print("");
             }
             for(int j = 1; j <= i; j++)
             {
                 System.out.print(j);
             }
             System.out.println();
         }
         
         
    }
    }
    2.2package com.itheima08;
    import java.util.*;
    public class HelloBudget {
    public static void main(String[] args ){
         for(int i = 6;i >= 1;i--) {
             for(int j = 1;j <= i;j++){
             System.out.print(j);
         }
         System.out.println();
         }
        
    }
    }
    2.3
    package com.itheima08;
    import java.util.*;
    public class HelloBudget {
    public static void main(String[] args ){
        for(int i = 1;i <= 6;i++)
        {  
            for(int j = 1;j <= 2 * (6 - i);j++)
                System.out.print(" ");
             
            for(int j = i;j >= 1;j--)
                System.out.printf(" %d",j);
            System.out.println();
        }
        System.out.println();
    }
    }
    2.4
    package com.itheima08;
    import java.util.*;
    public class HelloBudget {
    public static void main(String[] args ){
        for(int i=6;i>0;i--) {
            for(int k=0;k<6-i;k++) {
            System.out.print(" ");
            }
            for(int j = 1;j <= i;j++) {
            System.out.print(j);
            }
            System.out.println();
        }
        
    3.package com.itheima08;
    import java.util.*;
    public class HelloBudget {
    public static void main(String[] args ){
    Scanner input=new Scanner(System.in);
            System.out.println("year");
            int year=input.nextInt();
            System.out.println("month");
            int month=input.nextInt();
            System.out.println("day");
            int day=input.nextInt();
            int total=0;
            for(int i=1;i<month;i++){
                switch(i){
                case 4:
                case 6:
                case 9:
                case 11:
                total+=30;
                break;
                case 2:
                    if(year%4==0&&year%100!=0||year%400==0)
                        total+=29;
                    else
                        total+=28;
                    break;
                    default:
                        total+=31;
                        break;
                }
                }
            total+=day;
            System.out.println("该天是第"+total+"天");
    }
    }
    
    
    
    
            
            
    
    4.package com.itheima08;
    import java.util.*;
    public class HelloBudget {
    public static void main(String[] args ){
    Scanner input=new Scanner(System.in);
            System.out.println("请输入一个四位数字");
            int i=input.nextInt(); 
            int ge = i / 1000; 
            int shi = i/ 100 % 10; 
            int bai = i / 10 % 10; 
            int qian = i % 10; 
            int j = qian * 1000 + bai * 100 + shi * 10 + ge; 
            System.out.println("反转后 数字为�" + j); 
        }
    }

  • 相关阅读:
    CodeCraft-19 and Codeforces Round #537 (Div. 2) B. Average Superhero Gang Power
    CodeCraft-19 and Codeforces Round #537 (Div. 2) A
    牛客寒假算法基础集训营1 C. 小a与星际探索
    牛客寒假算法基础集训营5 J 炫酷数学
    牛客寒假算法基础集训营5 A 炫酷双截棍
    pat 1136 A Delayed Palindrome
    pta 1140 Look-and-say Sequence (20 分)
    pta 1150 Travelling Salesman Problem (25 分)(模拟)
    2020年团体程序设计天梯赛 L3-1 那就别担心了
    2020年团体程序设计天梯赛 L2-4 网红点打卡攻略
  • 原文地址:https://www.cnblogs.com/1774ax/p/12619121.html
Copyright © 2020-2023  润新知