一道ACM题目 报错wrong answerChildren 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 ch

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/22 10:30:45
一道ACM题目报错wronganswerChildrenaretaughttoaddmulti-digitnumbersfromright-to-leftonedigitatatime.Manyfin

一道ACM题目 报错wrong answerChildren 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 ch
一道ACM题目 报错wrong answer
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.The last line of input contains 0 0.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.
Sample Input123 456
555 555
123 594
0 0
Output for Sample Input No carry operation.
3 carry operations.
1 carry operation.
作答:
#include
using namespace std;
int main()
{
string s1,s2;
int n=0,N=0;
int b=1;
while(b=1)
{
cin>>s1>>s2;
int c1=s1.length()-1;
int c2=s2.length()-1;
if(s1[0]=='0'&&s2[0]=='0'&&c1==0&&c2==0)break;
else
while(c1>-1&&c2>-1)
{
if(s1[c1]+s2[c2]+N>105)
N=1,n+=1;
else N=0;
c1--,c2--;
}
if(c1>-1&&s2[c2]+N>9)n+=1;
if(c2>-1&&s1[c1]+N>9)n+=1;
if(n==0)cout

一道ACM题目 报错wrong answerChildren 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 ch
加上头文件#include
s1[c1]+s2[c2]是字符相加,不是数字相加.所以是字符5加字符5.字符5的ascll码是53,所以是s1+s2是106

一道ACM题目 报错wrong answerChildren 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 ch 一道acm题目 报错是wrong answer 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 significan ACM 2453 Wrong Answer 我的输出结果正确,他却一直报错……DescriptionAs we known,data stored in the computers is in binary form.The problem we discuss now is about the positive integers and its binary form.Given a positive integer I,you acm stars题目意思是什么 一道ACM题目,麻烦帮我解释下题意举个例子帮我说明下题意 求助一道ACM题一道很简单的ACM题目,题在这里我写的代码如下:#include using namespace std;int main(){int n,m[30];cin>>n;for(int i=0;i=0;j--){cout acm的一道c语言问题 【求助】北大acm JudgeOnline 请问谁有用C语言编写的北大acm JudgeOnline上面的题目的代码?不要求全不要有,poj1094、poj1125、poj1251、poj1915、poj1979有这五道题最好,或者一道都行啊(提供个链接都行) acm题目的a+b用c语言怎么写我写的是#includeint main(){int a,b;while(scanf(%d %d,&a,&b)==2){printf(%d ,a+b);}return 0;}他说wrong answer 生活报我以_______,我是_________五年级课本上的一道题目 一道虚拟语气的题目,Whether she be right or wrong ,she will have my unswering support... 杭电acm 1008 题我的为什么是wrong answer 一道acm的排序题Snow_storm有n(0 一道ACM 数字统计 描述:给出一个整数n(1 英文(ACM题目)的中文翻译去哪找最好! 求解ACM题目孪生素数请用C++代码 一道ACM题,帮忙看下哪儿错了⊙﹏⊙b汗题目:Description 还记得中学时候学过的杨辉三角吗?具体的定义这里不再描述,你可以参考以下的图形: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 Input 输入只包含 有关ACM一道题,你的任务是计算a+b.这是为了acm初学者专门设计的题目.你肯定发现还有其他题目跟这道题的标题类似,这些问题也都是专门为初学者提供的.输入格式输入包含一系列的a和b对,通