Created
September 20, 2016 18:20
-
-
Save splitline/fa533b5505daa3f2864786ec7186f91b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main(){ | |
char in[100]; | |
int m,n; | |
while(scanf("%s%d%d",&in,&m,&n)!=EOF){ | |
getchar(); | |
char chr=getchar(); | |
int len1=0,len2=0,flag=1; | |
for(int i=0;i<strlen(in);i++){ | |
if(in[i]=='.'){ | |
flag=0; | |
} | |
else if(flag){ | |
len1++; | |
} | |
else if(!flag) { | |
len2++; | |
} | |
} | |
if(len1+n+1<m){ | |
for(int i=0;i<m-len1-n-1;i++){ | |
printf("%c",chr); | |
} | |
} | |
if(len2>n){ | |
for(int i=0;i<len1+n+1;i++){ | |
printf("%c",in[i]); | |
} | |
} | |
if(len2<=n){ | |
for(int i=0;i<len1+len2;i++){ | |
printf("%c",in[i]); | |
} | |
if(len2>0) | |
printf("%c",in[len1+len2]); | |
if(len2==0) | |
printf("."); | |
for(int i=0;i<n-len2;i++){ | |
printf("0"); | |
} | |
} | |
printf("\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment