用"+,-"运算符计算整数x除以整数y的商和余数  
怎么做啊。。高手请指教哈

解决方案 »

  1.   

    int count=0;
    int yushu=x;
    for(;yushu>y;count++)
    yushu-=y;
    商是:count余数是yushu
      

  2.   

    循环减法 计算次数
    public class Test { public static void main(String[] args) {
    int x = 10, y = 1;
    int quotient = 0, residue = 0;
    while (x >= y) {
                x -= y;
                quotient += 1;
    }
    residue = x;

    System.out.println("The Quotient is: " + quotient);
    System.out.println("The Residue is: " + residue);
    }}
      

  3.   

    while(x-y<0){
    x=x-y;
    shang++;}