标签:als return std scanf strlen eof \n false ==
#include<stdio.h> #include<string.h> struct bign { int d[21], len; bign() { memset(d, 0, sizeof(d)); len = 0; } }; bign change(char str[]) { bign a; a.len = strlen(str); for (int i = 0; i < a.len; i++) { a.d[i] = str[a.len - i - 1] - ‘0‘; } return a; } bign multi(bign a, int b) { bign c; int carry = 0; for (int i = 0; i < a.len; i++) { int temp = a.d[i] * b + carry; c.d[c.len++] = temp % 10; carry = temp / 10; } while (carry != 0) { //** c.d[c.len++] = carry % 10; carry /= 10; } return c; } bool Judge(bign a, bign c) { if (a.len != c.len) return false; int count[10] = { 0 }; for (int i = 0; i < a.len; i++) { count[a.d[i]]++; count[c.d[i]]--; } for (int i = 0; i < 10; i++) { if (count[i] != 0) return false; } return true; } int main() { char str[21]; scanf("%s", str); bign a = change(str); bign c = multi(a, 2); if (Judge(a, c) == true) printf("Yes\n"); else printf("No\n"); for (int i = c.len - 1; i >= 0; i--) { printf("%d", c.d[i]); } return 0; }
1023 Have Fun with Numbers (20)
标签:als return std scanf strlen eof \n false ==
原文地址:https://www.cnblogs.com/Yaxadu/p/9190919.html