题解 | #还是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;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务