酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

#include<stdio.h> #include <string.h> int main() { int n, m; scanf("%d %d", &n, &m); char str_n[20], str_m[20]; sprintf(str_n, "%d", n); sprintf(str_m, "%d", m); int count_n[10] = {0}; int count_m[10] = {0}; for (int i = 0; i < strlen(str_n); i++) { count_n[str_n[i] - '0']++; } for (int i = 0; i < strlen(str_m); i++) { count_m[str_m[i] - '0']++; } int unique_n = 0, unique_m = 0; for (int i = 0; i < 10; i++) { if (count_n[i] > 0) unique_n++; if (count_m[i] > 0) unique_m++; } if (unique_n >

It seems like the code you provided is incomplete and has been cut off at the end. However, I can help you complete it based on what you have so far. The code appears to be counting the number of unique digits in two integers `n` and `m`. The counts are stored in arrays `count_n` and `count_m`, respectively. Then, the number of unique digits for each integer is calculated by checking how many elements in these arrays are greater than zero. To complete the code, you need to decide what you want to do with the counts of unique digits. For example, you might want to print them out, compare them, or use them in some other way. Here's an example of how you could print out the number of unique digits for both `n` and `m`: ```c #include<stdio.h> #include <string.h> int main() { int n, m; scanf("%d %d", &n, &m); char str_n[20], str_m[20]; sprintf(str_n, "%d", n); sprintf(str_m, "%d", m); int count_n[10] = {0}; int count_m[10] = {0}; for (int i = 0; i < strlen(str_n); i++) { count_n[str_n[i] - '0']++; } for (int i = 0; i < strlen(str_m); i++) { count_m[str_m[i] - '0']++; } int unique_n = 0, unique_m = 0; for (int i = 0; i < 10; i++) { if (count_n[i] > 0) unique_n++; if (count_m[i] > 0) unique_m++; } printf("Number of unique digits in %d: %d\n", n, unique_n); printf("Number of unique digits in %d: %d\n", m, unique_m); return 0; } ``` This code will print out the number of unique digits in both `n` and `m`. If you had a different requirement in mind, please provide more details so that I can assist you further. [2024-10-18 11:48:35 | AI写代码神器 | 566点数解答]

相关提问