编写一个程序段,完成如下任务:
(1)计算整数a除以整数b的商的整数部分:
(2)计算整数a除以整数b的整数余数:
(3)使用(1)与(2)中开发的程序块编写一个方法displayDigits,接收1到99999之间的一个整数并将其显示为一个数字序列,将每个数位之间空两个格。例如,接收1234   显示 1  2  3  4
(4)调用(3)里的方法,显示结果

解决方案 »

  1.   

    这个,除了“使用(1)与(2)中开发的程序块编写一个方法displayDigits”这个不知道是什么意思外,有点基础的人应该都可以做得出来。
      

  2.   

    public class Qiuyu
    {
    public static void main(String args [])
    {
    int a=901;
    int b=5;
    int c=a/b;
    int d=a%b;
    System.out.println(c);
    System.out.println(d);
    }
    }
      

  3.   

    不知道对不对 ,lz看下吧。
    #include <windows.h>
    #include <iostream>
    using std::cin;
    using std::cout;
    using std::endl;int GetQuotien(int a, int b)
    {
    return a / b;
    }int  GetRemainder(int a, int b)
    {
    return a % b;
    }
    int  GetNumber()
    {
    int Number = 0;
    cout << "Please input the Number bettween 1 to 99999" << endl;
    cin >> Number;
    return Number;
    }
    void DisplayDigits(int b)
    {
    int a = b;
    while(( a > 1 ) && ( a < 99999))
    {
        if(a > 9999)
    {
    cout << ( a / 10000 );
    }
    a = a % 10000;
        if(a > 999)
    {
    cout << "  " << ( a / 1000 );
    }
    a = a % 1000;
    if (a > 99)
    {
    cout << "  " << ( a / 100 );
    }
    a = a % 100;
    if (a > 9)
    {
    cout << "  " << ( a / 10 );
    }
    a = a % 10;
    cout << "  " << a;
    break;
    }
    }
    void main()
    {
    DisplayDigits(GetNumber());
    system("pause");
    }
      

  4.   

    错了,1 和 2 的模块没用上,稍微改点 吧。。
    #include <windows.h>
    #include <iostream>
    using std::cin;
    using std::cout;
    using std::endl;int GetQuotien(int a, int b)
    {
    return a / b;
    }int  GetRemainder(int a, int b)
    {
    return a % b;
    }
    int  GetNumber()
    {
    int Number = 0;
    cout << "Please input the Number bettween 1 to 99999" << endl;
    cin >> Number;
    return Number;
    }
    void DisplayDigits(int b)
    {
    int a = b;
    while(( a > 1 ) && ( a < 99999))
    {
        if(a > 9999)
    {
    cout << GetQuotien( a ,10000 );
    }
    a = GetRemainder(a,10000);
        if(a > 999)
    {
    cout << "  " <<GetQuotien( a , 1000 );
    }
    a = GetRemainder(a,1000);
    if (a > 99)
    {
    cout << "  " <<GetQuotien( a , 100 );
    }
    a = GetRemainder(a,100);
    if (a > 9)
    {
    cout << "  " <<GetQuotien( a , 10 );
    }
    a = GetRemainder(a,10);
    cout << "  " << a;
    break;
    }
    }
    void main()
    {
    DisplayDigits(GetNumber());
    system("pause");
    }