[英]Find the sum of digits and product of digits and then the difference of them
以'n'作为输入的第一行('n'是总位数)。 然后在新行中输入带有“n”位的数字。 求数字的总和和数字的乘积,然后求它们的差。
这里是 go。
int main () {
int n, product = 1, sum = 0;
cin >> n;
int arr[n];
for(int i=0; i<n; i++) {
product *= arr[i];
sum += arr[i];
}
int difference = product - sum;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.