题解 | #游游的整数切割#

游游的整数切割

https://www.nowcoder.com/practice/c01b07fe9623425a806c85cdb6f0e0f7

#include <stdio.h>
#include <string.h>

int main() {
    char num[10100001];
    scanf("%s", num);
    int len = strlen(num);
    int ans = 0;
    for (int i = 1; i < len; i++) {
        int left = 0, right = 0;
        for (int j = 0; j < i; j++) {
            left = (num[j]-'0');
        }
        for (int j = i; j < len; j++) {
            right =  (num[j]-'0');
        }
        if ((left + right) % 2 == 0) {
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

全部评论

相关推荐

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