Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
489 B
3
Indexable
Never
#include<stdio.h>
#include<math.h>

double a,b,sum;
int k;

int main(){
	//scanf("%lf %lf %d",&a,&b,&k)
	while(scanf("%lf %lf %d",&a,&b,&k)!=EOF){
		sum=a+b;
		sum=(int)(sum*pow(10,k+1)+5)/10;
		sum/=pow(10,k);
		if(k==0){
			printf("%d\n",(int)sum);
		}
		else if(k==1){
			printf("%.1f\n",sum);
		}
		else if(k==2){
			printf("%.2f\n",sum);
		}
		else if(k==3){
			printf("%.3f\n",sum);
		}
		else if(k==4){
			printf("%.4f\n",sum);
		}
		else if(k==5){
			printf("%.5f\n",sum);
		}
	}
}