int count=0; int yushu=x; for(;yushu>y;count++) yushu-=y; 商是:count余数是yushu
循环减法 计算次数 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); }}
int yushu=x;
for(;yushu>y;count++)
yushu-=y;
商是:count余数是yushu
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);
}}
x=x-y;
shang++;}