题解 | #数字阶梯求和#
数字阶梯求和
https://www.nowcoder.com/practice/c66df29f6c1c4dbba0bd51619210e082
#include <stdio.h>
int main() {
int a,n;
scanf("%d %d",&a,&n);
int temp_a[200]={0},sum[200]={0},top,c;
for(int i=0;i<n;i++){
temp_a[i]=a;
for(int j=0;j<=i;j++){
sum[j]+=temp_a[j];
c=sum[j]/10;
sum[j]%=10;
top=j;
while(c>0){
sum[++top]+=c%10;
c/=10;
}
}
}
for(int j=top;j>=0;j--){
printf("%d",sum[j]);
}
return 0;
}
查看3道真题和解析
