这... 算作弊了吧
import java.util.Scanner;
/**
* @author Allen_Hua
* @create_time 创建时间:May 10, 2018 3:43:56 PM 类说明
*/
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
int n = scan.nextInt();
System.out.println(Integer.toOctalString(n));
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print(Integer.toOctalString(in.nextInt()));
}
}
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int nextInt = in.nextInt();
int num = 0;
int i = 0;
while (nextInt!=0) {
num += nextInt%8*Math.pow(10, i);
nextInt /=8;
i++;
}
System.out.println(num);
}
}
单机通过,不能AC
public class Main {
public void doSome(int in){
List<Integer> list=new ArrayList<Integer>();
int did=8;
int record=0;
if(in>=0&&in<=7){
System.out.println(in);
}
if(in>=8){
while(in>0){
int temp=in%did;
list.add(temp);
in/=did;
}
for(int i=list.size()-1;i>=0;i--){
System.out.print(list.get(i));
}
}
}
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
Main m=new Main();
int input;
while(true){
input=s.nextInt();
m.doSome(input);
}
}
}
牛客网的**编译器说不成功!
import java.util.Scanner;
public class Main {
public static void main (String args []) {
Main octo = new Main();
Scanner scanner = new Scanner(System.in);
while(scanner.hasNextInt()){
int number = scanner.nextInt();
System.out.println(octo.dec2oct(number));
}
}
int dec2oct(int dec) {
String oct = "";
int quotient = dec;
int reminder;
while (quotient >= 8) {
reminder = quotient % 8;
quotient = quotient / 8;
oct = oct + reminder;
}
oct = oct + quotient;
StringBuffer sb = new StringBuffer(oct);
sb.reverse();
oct = sb.toString();
return Integer.parseInt(oct);
}
}
import java.util.Scanner; public class Main{
public static void main(String[] arg){
Scanner scan = new Scanner(System.in);
while(scan.hasNext()){
String octer = String.valueOf(Integer.toOctalString(Integer.parseInt(scan.nextLine())));
System.out.println(octer);
}
}
}
// 采用递归的方法 import java.util.Scanner; /** * Created by Yuan on 2017/3/2. */ public class te { public static void main(String[] args){ Scanner scanner=new Scanner(System.in); while(scanner.hasNext()){ int num= scanner.nextInt(); changeNum(num); System.out.println(); } } public static void changeNum(int num){ if(num==0) return; int mod=num%8; int div=num/8; changeNum(div); System.out.print(mod); } }