赞
踩
计算a+aa+aaa+aaaa+…+aaa…aaa(n个a)的值,n和a的值由键盘输入
#include<stdio.h> #include<math.h> int main() { int n, sum = 0, a,i=0; int temp = 0; printf("输入两个数\n"); scanf("%d,%d", &a, &n); while (i < n) { int c = a * pow((double)10,(double) i); temp += c; sum += temp; i++; } printf("%d\n", sum); return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。