#include "cstdio"
using namespace std;
int main() {
char a[10], b[10];
int result = 0;
scanf("%s %s", a, b);
for (int i = 0; a[i] != '\0'; i++) {
for (int j = 0; b[j] != '\0'; j++) {
result += int(a[i] - '0') * int(b[j] - '0');
}
}
printf("%d\n", result);
return 0;
}
用 char类型 强制类型转换成 Int类型
其中 result+= int(a[i]-'0')*int(b[j]-'0'); 这行 运用了 char的ASICL码,减去'0'再强制类型转化,就是对应的 Int型整数了.

京公网安备 11010502036488号