Created
September 20, 2016 17:56
-
-
Save splitline/7735b124ac3c43a339ded8d8e0ccdd73 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 flag=-1; | |
char s1[100],s2[100]; | |
memset(s1,'\0',sizeof(s1)); | |
memset(s2,'\0',sizeof(s2)); | |
for(int i=0;i<strlen(in);i++){ | |
if(in[i]=='.'){ | |
flag=i; | |
} | |
else{ | |
s1[i]=in[i]; | |
} | |
} | |
if(flag==-1){ | |
int nnum=m-n-1-strlen(in); | |
if(nnum>=0){ | |
for(int i=0;i<nnum;i++){ | |
printf("%c",chr); | |
} | |
} | |
printf("%s.",in); | |
for(int i=0;i<n;i++){ | |
printf("0"); | |
} | |
} | |
else{ | |
for(int i=flag+1;i<strlen(in);i++){ | |
s2[i-flag-1]=in[i]; | |
} | |
//printf("%s",s2); | |
int numm=m-n-1-strlen(s1); | |
if(numm>=0){ | |
for(int i=0;i<numm;i++){ | |
printf("%c",chr); | |
} | |
} | |
printf("%s.",s1); | |
int num = n-strlen(s2); | |
if(num>=0){ | |
printf("%s",s2); | |
for(int i=0;i<n-strlen(s2);i++){ | |
printf("0"); | |
} | |
} | |
else{ | |
for(int i=0;i<n;i++){ | |
printf("%c",s2[i]); | |
} | |
} | |
} | |
printf("\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment