首页 > 试题广场 >

Primary Arithmetic

[编程题]Primary Arithmetic
  • 热度指数:3134 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
    Children are taught to add multi-digit numbers from right-to-left one digit at a time. Many find the "carry" operation - in which a 1 is carried from one digit position to be added to the next - to be a significant challenge. Your job is to count the number of carry operations for each of a set of addition problems so that educators may assess their difficulty.

输入描述:
    Each line of input contains two unsigned integers less than 10 digits. 


输出描述:
    For each line of input except the last you should compute and print the number of carry operations that would result from adding the two numbers, in the format shown below.
示例1

输入

123 456
555 555
123 594
0 0

输出

NO carry operation.
3 carry operations.
1 carry operation.
头像 子豪不自豪
发表于 2024-01-07 09:08:49
#include <stdio.h> #include <string.h> //非常简单的代码,应该一目了然,就不解释了 int main() { int a,b; while (scanf("%d %d", &a, & 展开全文
头像 牛客440904392号
发表于 2024-10-02 11:18:31
#include <iostream> using namespace std; int main() { int a, b; while (cin >> a >> b) { if (a == 0 && b == 0 展开全文
头像 T790T
发表于 2024-08-14 10:33:48
#include <iostream> using namespace std; int main() { string x,y; while(cin>>x>>y && x!="0" && y! 展开全文
头像 用户抉择
发表于 2021-03-11 21:36:22
实际上不用计算加法。 #include <stdio.h> #include <string.h> int main() {     char a[10],b[10];  &nbs 展开全文
头像 牛客596495425号
发表于 2025-03-16 15:18:00
#include <iostream> #include <cstring> #include <algorithm> #include <vector> using namespace std; int add(vector<int> 展开全文
头像 粉詹眉
发表于 2024-02-16 16:21:59
#include <iostream> using namespace std; int main() { string x, y; while (cin >> x >> y) { if (x == "0" 展开全文
头像 chong_0428
发表于 2024-03-21 22:51:27
def fun(a): res = [] while a >0: t = a % 10 a = a / 10 res.append(t) return res def add(a, b): a = fun(a) 展开全文
头像 Brillianman
发表于 2023-02-11 20:55:58
#include<stdio.h> #include<string.h> int main() { int i, j, A[20], B[20]; char S1[20], S2[20]; scanf("%s %s", S1, S2); fo 展开全文
头像 陶良策
发表于 2025-02-23 22:46:51
#include <iostream> using namespace std; int main() { unsigned long a, b; while (cin >> a >> b) { // 注意 while 处理多个 case 展开全文
头像 牛客116735491号
发表于 2025-04-02 16:19:01
#include <bits/stdc++.h> using namespace std; int main() { string a, b; while (cin >> a >> b) { // 注意 while 处理多个 case 展开全文

问题信息

难度:
36条回答 8035浏览

热门推荐

通过挑战的用户

查看代码
Primary Arithmetic