zoukankan      html  css  js  c++  java
  • 第五次上机作业

    1.

    import java.util.*;
    public class jkk {
        public static void main(String[] args) {
             for(int i=100;i<1000;i++) {
                 int ge=i%10;
                 int shi=i/10%10;
                 int bai=i/100;
                 if(ge*ge*ge+shi*shi*shi+bai*bai*bai==i) {
                     System.out.println(i);
                 }
             }
         }
     }

    2.

    package calsswork;
    import java.util.Scanner;
    public class text1 {
        public static void main(String[] args) {
            for(int i=1;i<=7;i++) {
                for(int j=1;j<i;j++) {
                    System.out.print(j);
                }
                System.out.println();
            }
        }
    }

    package hello;
    import java.util.Scanner;
    public class yes {
        public static void main(String[] args) {
            for(int i=6;i>=0;i--) {
                for(int j=1;j<=i;j++) {
                    System.out.print(j);
                }
                System.out.println();
            }
        }
    
    

    package hello;
    import java.util.Scanner;
    public class yes {
         public static void main(String[] args) {
                Scanner sc=new Scanner(System.in);
                 for(int a=1;a<7;a++) {
                        for(int b=a;b>0;b--) {
                            System.out.print(b);
                        }
                        System.out.println();
            
        }
    }
    }

    package hello;
    import java.util.Scanner;
    public class yes {
         public static void main(String[] args) {
             
                    Scanner sc=new Scanner(System.in);
                    for(int a=6;a>0;a--) {
                        for(int b=0;b<6-a;b++) {
                            System.out.print(" ");
                        }
                        for(int i=1;i<=a;i++) {
                            System.out.print(i);
                        }
                        System.out.println("");
                    }
                }
            }

    3.

    package hello;
    import java.util.Scanner;
    public class yes {
        public static void main(String[] args) {
              int year;
                int mouth;
                int day = 0;
                int days;
                int d = 0; // 累计天数
                int e = 0;
                Scanner scanner = new Scanner(System.in);
                
                //判断输入的年份和月份和日期是否错误
                do {
                    System.out.println("输入年:");
                    year = scanner.nextInt();
                    System.out.println("输入月:");
                    mouth = scanner.nextInt();
                    System.out.println("输入日:");
                    days = scanner.nextInt();
                    if (year < 0 || mouth < 0 || mouth > 12 || days < 0 || days > 31) {
                        System.out.println("input error!");
                        e = 1;
                    }
                } while (e == 1);
                
                for (int i = 1; i < mouth; i++) {
                    switch (i) {
                    case 1:
                    case 3:
                    case 5:
                    case 7:
                    case 8:
                    case 10:
                    case 12: {
                        day = 31;
                        break;
                    }
                    case 4:
                    case 6:
                    case 9:
                    case 11: {
                        day = 30;
                        break;
                    }
                    case 2: {
                        if ((year % 100 != 0 && year % 4 == 0) || (year % 100 == 0 && year % 400 == 0)) {
                            day = 29;
                        } else {
                            day = 28;
                        }
                    }
                    default:
                        break;
                    }
                    d += day;
                }
                System.out.println("这是" + year + "年的" + (d + days) + "天");
        }
    }

    4.

    package hello;
    import java.util.Scanner;
    public class yes {
         public static void main(String[] args) {
             
              Scanner sc=new Scanner(System.in);
               System.out.println("请输入一个四位数");
               int x=sc.nextInt();
               
                   int gewei=x%10;
                   int shiwei=x%10/10;
                   int baiwei=x%100/100;
                   int qianwei=x/1000;
                  
                   System.out.println("原先的数为:"+x+"现在的为"+(qianwei+baiwei*10+shiwei*100+gewei*1000));
               }
                }

  • 相关阅读:
    内存中的堆和栈
    数据库——关系型数据库
    如何创建一个进程,如何进程调用进程
    浅谈C++之冒泡排序、希尔排序、快速排序、插入排序、堆排序、基数排序性能对比分析(好戏在后面,有图有真相)
    Moon.Orm 5.0(MQL版)使用指南
    初学 快速幂 的理解
    2016 杭电
    2015 偶数求和 AC 杭电
    2014 青年歌手大赛 AC
    C语言初学 数组 打印菱形
  • 原文地址:https://www.cnblogs.com/cmk521/p/12619059.html
Copyright © 2011-2022 走看看