题目描述
小明最近多位数加法运算学的很晕倒:(,幸好是做判断题,它只需要判断A+B最后一位数是否是C就可以了,可是他真的懒的厉害,这不让你写一个程序帮助他
输入
两个长度超过100位整数A B 一个个位数C
输出
正确与否,正确是YES 错误则输出NO
样例输入
999999999999999999999999999999999999999999999999999999999999999999999999 88888888888888888888888888888888888888888888888 7
样例输出
YES
C源码
#include <stdio.h>
#include <string.h>
int main()
{
char a[1000],b[1000];
int c,d,e;
scanf("%s%s%d",a,b,&c);
d=strlen(a);
e=strlen(b);
if((a[d-1]-'0'+b[e-1]-'0')%10==c||(b[e-1]-'0'+a[d-1]-'0')%10==c) //字符常量-'0'=数字常量,exp:8-'0'=8;
printf("YES");
else
printf("NO");
}
C++源码
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
string a;
string b;
int c;
cin>>a>>b;
cin>>c;
int n=(a[a.length()-1])+(b[b.length()-1]);
if(n%10==c)
{
printf("YES");
}
else
printf("NO");
}
441

被折叠的 条评论
为什么被折叠?



