首页 > 试题广场 >

Primary Arithmetic

[编程题]Primary Arithmetic
  • 热度指数:2867 时间限制: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 展开全文
头像 粉詹眉
发表于 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 展开全文
头像 爱喝零度可乐
发表于 2023-03-25 16:07:38
#include<cstdio> #include<stack> #include<vector> #include<string> using namespace std; int main() { char arr1[10]; ch 展开全文
头像 爱喝零度可乐
发表于 2023-03-25 16:09:02
所有的情况行云流水,还考虑到了两个数的位数不同的情况,供大家参考。 #include<cstdio> #include<stack> #include<vector> #include<string> using namespace std; int 展开全文
头像 lyw菌
发表于 2023-03-10 16:11:03
//大意为每个测试用例给两个整数,计算这两个整数相加的过程中产生的总进位数。 //多个测试用例,最后一行的0,0不用算 /* *感觉用字符串做更方便些 */ #include "stdio.h" #include "string" #include "algorithm" using namesp 展开全文

问题信息

难度:
36条回答 6908浏览

热门推荐

通过挑战的用户

查看代码
Primary Arithmetic