循环
各位大佬,我要求a+...+n个a,要怎么改?#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
int main(void)
{
int a, b, n, i, sum = 0;
srand(unsigned(time(NULL)));
a = 1 + rand() % 9;
printf("a=%d\n", a);
b = a;
scanf_s("%d", &n);
for (i = 1; i <= n; i++)
{
b =pow(10 , i)+ a;
sum +=b;
}
printf("%d\n", sum);
system("pause");
return 0;
}