LanQiaoTestCodes/进位模拟.java

22 lines
442 B
Java
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package Course_Codes;
//输入两个9位以内的数相加求其有多少进位
import java.util.Scanner;
public class 进位模拟 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int count=0,temp=0;//count——统计temp——存放进位
for(int i=0;i<9;i++) {
temp=(a%10+b%10)>=10?1:0;
count+=temp;
a/=10;
b/=10;
}
System.out.print(count);
}
}