题解 | #还是A+B#

还是A+B

https://www.nowcoder.com/practice/8c3c5dae2c4a4266ba04f993a18e286b

#include <stdbool.h>
#include <stdint.h>
#include<stdio.h>
bool f(int A,int B,int K)
{
    int i;
    for(i=0;i<K;i++)
    {
        if(A%10!=B%10)return false;
        A/=10;
        B/=10;
    }
    return true;
}
int main()
{
    int A,B,K;
    scanf("%d %d %d",&A,&B,&K);
    if(f(A,B,K)==true)printf("-1\n");
    else printf("%d\n",A+B);
    return 0;
}

全部评论

相关推荐

点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务