View Code of Problem 86

#include<stdio.h>
#include<math.h>
int main(){
	//输入两个正整数a和n,输出a+aa+aaa+…+a…a(n个a)之和。例如,输入2和3,输出246(2+22+222)。
	int a,n,sum=0,temp;
	scanf("%d %d",&a,&n);
	
	while(n){
		temp = n;
		while(temp){
			sum += a*pow(10,temp-1);
			temp --;
		}
		n--;
	}
	printf("%d",sum);
	return 0;
} 

Double click to view unformatted code.


Back to problem 86