我也是看的题解。题解 P1590 【失踪的7】 - iscreamgc445 的博客 - 洛谷博客
package cn.itcast.girl.TheBlueCup_02;
import java.util.Scanner;
public class MissingFigure {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long num,sum,count,temp;
for(int i=0;i<n;i++) {
num = sc.nextLong();
sum=0;count=0;
while(num>0) {
temp = num % 10;
if (temp < 7)
sum += temp * Math.pow(9, count);
else
sum += (temp-1) * Math.pow(9, count);
num/=10;
count++;
}
System.out.println(sum);
}
sc.close();
}
}