Problem Description: Calculates how many times the two integers need to be rounded up and processes multiple sets of data until they enter two 0.1.java
ImportJava.util.Scanner;/*** Statistics two number of times to add the amount of carry, the end of the flag input two 0 *@authorNEU-2015 **/ Public classDemo { Public Static voidMain (string[] args) {Scanner input=NewScanner (system.in); intA = 0; intb = 0; intCount = 0;//count How many times the rounding intresult = 0;//a+b The results of each number of digits while(Input.hasnext ()) {a=Input.nextint (); b=Input.nextint (); Count= 0; Result= 0; if(A = = 0 && b = = 0) {//End FlagInput.close (); Break; } while(A > 0 && B > 0) {result= (a%10 + b%10 + result) > 9? 1:0; Count+=result; A/= 10; b/= 10; } System.out.println (count); //How many times the output is rounded } }}
2.c
#include <iostream>#include<stdio.h>using namespacestd;//no more than 9 digits are entered for the integer//@author NEU-2015intMain () {intA, B; while(SCANF ("%d%d", &a, &b) = =2) { if(!a &&!b)return 0; intc =0, ans =0; for(inti =9; I >=0; i--) {C= (a%Ten+ b%Ten+ c) >9?1:0; Ans+=C; A/=Ten; b/=Ten; } printf ("%d\n", ans); } return 0;}
Elementary school students arithmetic-java&c-statistics How many occurrences occur when two integers are added together