一个人工作了89小时算他工作了多少天以及多少小时:
public class test {
public static void main(String[] args){
int total = 89;
int days;
days = total/24;
System.out.println(days);
    System.out.println(89%24);
   
}
}
这样我觉得虽然也算出来了 但是我觉得很不好我刚学!!!谅解!

解决方案 »

  1.   

    也没啊~~这样写蛮容易理解的啊~~而且算法不复杂!!
    加油~~我也正在学习中~~~多逛逛这个网站~~对立的java水平提高很有帮助!!
      

  2.   

    这个代码有问题啊,int days中days是局部变量,应该初始化之后才能编译通过,有IDE工具的话回直接提示你初始化变量。
      

  3.   

    定义类时首字母大写 public class Test 从一开始就要养成良好的习惯哈 加油!
      

  4.   


    不要信他的,没问题
    这个程序没什么不好,如果你要考虑改进的话,就从算法入手吧
    Java本来就很简单,不过还是建议你先学习C/C++
      

  5.   

    一个人工作了89小时算他工作了多少天以及多少小时:
    public class test {
    public static void main(String[] args){
    int total = 89;
    int days;
    days = total/24;
    System.out.println(days);
    System.out.println(89%24);}……
      

  6.   

    days好像没有初始化吧,不过不要紧,慢慢来嘛!一起努力~
      

  7.   

    /***************************************************
    *求一个人工作了89个小时,算他工作了多少天,多少个小时
    *****************************************************、
    public class Test {
      public static void main(String[] args){ 
        int total = 89;
        int days;
        days = total/24;
        System.out.println(days);
        int hours;
        System.out.println(89%24);    
      }
    }
      

  8.   

    public class test{
         public static void main(String[] args){
    int total = 89;
    System.out.printf("工作%d天,零%d小时\n",(total/24),(total%24));   
       }
    }//能少定义变量就少用
      

  9.   

    public class test 
    {
       public static void main(String[] args)
      { 
         System.out.println("一个工作了89个小时的人工作了"+89/24+"天又"+89%24+"个小时");
      }
    }
      

  10.   

    在工作中这个算法其实会经常用到
    比如你给你记录数算它的页数,给你页数和记录序号,你要知道该记录是第几条,数组循环队列
    对于数字的处理另外在java中常见的还有0-x,因为java是有符号数
      

  11.   

    很不错的啊,起码还知道int/int的运算,加油!