方案一:
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
//找规则,小于3个空瓶时为0;3个空瓶换1,4、5个空瓶换3,6、7个空瓶换3,,8、9个空换4,10个空换5
//总空瓶数量除以2,取整数,则为可以换的总数量
while(sc.hasNext()){
int m=sc.nextInt();
if(m!=0){
int n=m/2;
System.out.println(n);
}
}
}
}
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
//找规则,小于3个空瓶时为0;3个空瓶换1,4、5个空瓶换3,6、7个空瓶换3,,8、9个空换4,10个空换5
//总空瓶数量除以2,取整数,则为可以换的总数量
while(sc.hasNext()){
int m=sc.nextInt();
if(m!=0){
int n=m/2;
System.out.println(n);
}
}
}
}
方案二:
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
int num=sc.nextInt();
int count=0;
if(num ==0){
break;
}
//2瓶换一瓶
count=num/2;
System.out.println(count);
}
}
}
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
int num=sc.nextInt();
int count=0;
if(num ==0){
break;
}
//2瓶换一瓶
count=num/2;
System.out.println(count);
}
}
}