输入在一行中依次给出A、DA、B、DB,中间以空格分隔,其中0 < A, B < 1010。
在一行中输出PA + PB的值。
3862767 6 13530293 3
399
import java.util.Scanner; /** * @ClassName Main * @Description TODO * @Author Wlison * @Date 2020/3/11 9:38 * @Version 1.0 **/ public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int d = sc.nextInt(); String as = ""; String cs = ""; while(a!=0){ if (a%10==b) as+=b; a/=10; } while(c!=0){ if (c%10==d) cs+=d; c/=10; } a=as.equals("")?0:Integer.parseInt(as); c=cs.equals("")?0:Integer.parseInt(cs); System.out.println(a+c); } } }
import java.util.Scanner;
public class Test1006 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int A,DA,B,DB,PA=0,PB=0;
A = scan.nextInt();
DA = scan.nextInt();
B = scan.nextInt();
DB = scan.nextInt();
PA=P(A,DA);
PB=P(B,DB);
System.out.println(PA+PB);
}
public static int P(int A,int DA) {
int PA=0,count=1;
while(A>0) {
if(A%10==DA) {
PA+=count*DA;
count*=10;
}
A/=10;
}
return PA;
}
}
import java.util.Scanner; public clas***ain { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(), da = scanner.nextInt(), b = scanner.nextInt(), db = scanner.nextInt(), pa = 0, pb = 0; char[] arrayA = String.valueOf(a).toCharArray(); int flag = 0; for (int i = 0; i < arrayA.length; i++) { if (arrayA[i] == String.valueOf(da).toCharArray()[0]) { pa += Math.pow(10, flag) * da; flag++; } } char[] arrayB = String.valueOf(b).toCharArray(); int flag2 = 0; for (int i = 0; i < arrayB.length; i++) { if (arrayB[i] == String.valueOf(db).toCharArray()[0]) { pb += Math.pow(10, flag2) * db; flag2++; } } System.out.println(pa + pb); } }
import java.util.Scanner; public class Main{ private static int han(String a,int b) { int p=0; int o=0; for(int i=0;i<a.length();i++) { if(a.charAt(i)-'0'==b) { p++; } } for(int i=0;i<p;i++) { o+=b*Math.pow(10, i); } return o; } public static void main(String[] args) { Scanner in=new Scanner(System.in); while(in.hasNext()) { String a=in.next(); int b=in.nextInt(); String c=in.next(); int d=in.nextInt(); System.out.println(han(a,b)+han(c,d)); } } }
import java.util.Scanner;
public class Main {
private static Scanner sc;
public static void main(String[] args) {
sc = new Scanner(System.in);
int A = sc.nextInt();
int DA = sc.nextInt();
int PA = 0;
int B = sc.nextInt();
int DB = sc.nextInt();
int PB = 0;
while(A > 0) {
if(A % 10 == DA) {
PA = PA * 10 + DA;
}
A /= 10;
}
while(B > 0) {
if(B % 10 == DB) {
PB = PB * 10 + DB;
}
B /= 10;
}
System.out.println(PA + PB);
}
}
import java.util.Scanner; /* 输入在一行中依次给出A、DA、B、DB,中间以空格分隔,其中0 < A, B < 1010。 输出描述: 在一行中输出PA + PB的值。 输入例子: 3862767 6 13530293 3 输出例子: 399 */ /* author: MR.Yang date:2018.05.26 */ /* 思路:用了一个Math.pow(double a,int b)方法(a的b次幂)求P的值 参数a表示底数,b表示指数 传回的数值是double类型 */ public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int A = in.nextInt(); int DA = in.nextInt(); int B = in.nextInt(); int DB = in.nextInt(); Main main = new Main(); int Pa = main.getP(A,DA); int Pb = main.getP(B,DB); System.out.println(Pa+Pb); } public int getP(int A,int B){ int count = 0; int P=0; while(A != 0){ if(A%10 == B){ count++; } A = A/10; } for(int i=0; i<count; i++){ P = P + ((int)(Math.pow(10,i)))*B; } return P; } }
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = newScanner(System.in);int A = scanner.nextInt();int Da = scanner.nextInt();int B = scanner.nextInt();int Db = scanner.nextInt();int pa = calculateP(A, Da);int pb = calculateP(B, Db);System.out.println(pa + pb);scanner.close();}private static int calculateP(int num1, int num2) {int count = 0, newNum = 0;while(num1 != 0) {if(num1 % 10== num2)count++;num1 = num1 / 10;}if(count > 0) {for(inti = 0; i < count; i++) {newNum = newNum * 10+ num2;}}return newNum;}}
//【java】28行若此处写String part ="";case通过率75?因为也可能没匹配到,就是0了import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String []a = new String[4];
for (int i = 0; i < a.length; i++) {
a[i]=scanner.next();
}
scanner.close();
System.out.println(getPart(a[0],a[1])+getPart(a[2],a[3]));
}
public static int getPart(String str1,String str2) {
char []c = str1.toCharArray();
String part = "0";//若此处写="";case通过率75???什么原因
for (int i = 0; i < c.length; i++) {
if (str2.equals(c[i]+"")) {
part=part + str2;
}
}
return Integer.parseInt(part);
}
}
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); String[] parameters = line.split(" "); int PA = 0; int PB = 0; int DA = Integer.parseInt(parameters[1]); int DB = Integer.parseInt(parameters[3]); for(int i = 0; i < parameters[0].length(); i++) { if(parameters[0].charAt(i) == parameters[1].charAt(0)) { PA = PA * 10 + DA; } } for(int i = 0; i < parameters[2].length(); i++) { if(parameters[2].charAt(i) == parameters[3].charAt(0)) { PB = PB * 10 + DB; } } System.out.println(PA + PB); } }
import java.util.Scanner;
public class Main {
String result;
String A,B,A1,B1;
char DA,DB;
public Main() {
Scanner sc=new Scanner(System.in);
A=sc.next();
A1=sc.next();
B=sc.next();
B1=sc.next();
int a=Integer.parseInt(D(A,A1.charAt(0)));
int b=Integer.parseInt(D(B,B1.charAt(0)));
System.out.println(a+b);
}
public String D(String A,char DA) {
result="";
for(int i=0;i<A.length();i++) {
if(A.charAt(i)==DA)
result+=DA;
}
if(result=="")
result="0";
return result;
}
public static void main(String[] args) {
Main p=new Main();
}
}
import java.util.Scanner; public class Main { public static int method(int A, int Da) { int Pa = 0; int i = 0; while (A > 0) { if (A % 10 == Da) { Pa += Math.pow(10, i) * Da; i++; A /= 10; } else { A /= 10; } } return Pa; } @SuppressWarnings("resource") public static void main(String[] args) { Scanner in = new Scanner(System.in); int A = in.nextInt(); int Da = in.nextInt(); int B = in.nextInt(); int Db = in.nextInt(); System.out.println(method(A, Da) + method(B, Db)); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long A = sc.nextLong(); int DA = sc.nextInt(); long B = sc.nextLong(); int DB = sc.nextInt(); System.out.println(transTo(A, DA)+transTo(B, DB)); } public static int transTo (long a, int b){ char str [] = new String(a+"").toCharArray(); String P =""; for (char c : str) { if(Integer.parseInt(c+"")==b){ P = P + b; } } if(P.equals("")){ return 0; }else{ return Integer.parseInt(P); } } }
import java.util.Scanner;
public class Main{
@SuppressWarnings("resource")
public static void main(String[] args) {
int a=0;
int b=0;
int Da = 0;
int Db=0;
Scanner sc = new Scanner(System.in);
a = sc.nextInt();
Da = sc.nextInt();
b = sc.nextInt();
Db = sc.nextInt();
int numa = 0;
String stra = String.valueOf(a);
for(int i =0;i<stra.length();i++){
if(stra.charAt(i)==String.valueOf(Da).charAt(0)){
numa++;
}
}
int numb = 0;
String strb = String.valueOf(b);
for(int i =0;i<strb.length();i++){
if(strb.charAt(i)==String.valueOf(Db).charAt(0)){
numb++;
}
}
System.out.println(getNum(Da,numa)+getNum(Db,numb));
}
public static int getNum(int n,int num){
int a=n;
int b =0;
for(int i=0;i<num;i++){
b+=a;
a=a*10;
}
return b;
}
}