1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import java.util.*; /** * UVA10035 */ public class UVA10035 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int n1 = sc.nextInt(), n2 = sc.nextInt(); if (n1 == 0 && n2 == 0) break; int times = 0; int carry = 0; while (n1 != 0 || n2 != 0) { int r1 = n1 % 10; int r2 = n2 % 10; carry = (r1 + r2 + carry) / 10; times += carry; n1 /= 10; n2 /= 10; } System.out.printf("%s carry operation%s.\r\n", times > 0 ? Integer.toString(times) : "No", times > 1 ? "s" : ""); } sc.close(); } }; |