不使用 / 和 % 解汽水瓶
汽水瓶
http://www.nowcoder.com/questionTerminal/fe298c55694f4ed39e256170ff2c205f
java小白第一次把自己写的代码发上来,没有使用 / 和 %
请大家批评指正
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNextInt()){
int a = sc.nextInt();
if(a==0){
System.out.println();
return;
}
int b = a;
int count = 0;
while(b>=3){
b -= 3;
count++;
b += 1;
}
if(b==2){
System.out.println(count+1);
}else{
System.out.println(count);
}
}
}
}
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNextInt()){
int a = sc.nextInt();
if(a==0){
System.out.println();
return;
}
int b = a;
int count = 0;
while(b>=3){
b -= 3;
count++;
b += 1;
}
if(b==2){
System.out.println(count+1);
}else{
System.out.println(count);
}
}
}
}