要求:
用兩個函數
//返回要求的和
sumA(int a, int n);
//返回n個a組成的數字
int fn( int a, int n);函數
輸入輸出:
spa
main函數實現,以下:code
int main() { int a, n; scanf("%d %d",&a,&n); printf("fn(%d , %d) = %d\n", a, n, fn(a, n)); printf("s = %d\n", SumA(a, n)); return 0; }
fn函數實現,以下:it
int fn( int a, int n) { int sum1 = 0; for(int i = 1; i<=n; i++) { sum1 += a; a *= 10; } return sum1; }
sumA函數實現,以下:class
int SumA( int a, int n) { int sum2 = 0; int sign = 0; for(int i = 1; i<=n; i++) { sum2 += a; a *= 10; sign += sum2; } return sign; }