Skip to main content
added tio
Source Link
girobuz
  • 389
  • 2
  • 8

C, 209 203203 137 bytes

-66 bytes thanks to ceilingcat

mainchar a[9];main(b,c,f){c=b=0;char a[99]={0};getsgets(a);f=strlen(a)-3;a[f+1]=0;if3;a[f+1]=0;printf(a[f]==98||(*a==48&&!f))b=1;if(*a=='-'&&a[1]==49&&f==1)*a==55&a[1]==49&f==1?a[1]=98,b=1;if(*a==49&&:*a==49&!f)?*a=98,b=1;if(b:a[f]==98|*a==48&!f){printf(?"%s",a);return;}printf(:"%sb",a);}

TIO

C, 209 203 bytes

main(b,c,f){c=b=0;char a[99]={0};gets(a);f=strlen(a)-3;a[f+1]=0;if(a[f]==98||(*a==48&&!f))b=1;if(*a=='-'&&a[1]==49&&f==1)a[1]=98,b=1;if(*a==49&&!f)*a=98,b=1;if(b){printf("%s",a);return;}printf("%sb",a);}

C, 209 203 137 bytes

-66 bytes thanks to ceilingcat

char a[9];main(f){gets(a);f=strlen(a)-3;a[f+1]=0;printf((*a==55&a[1]==49&f==1?a[1]=98:*a==49&!f?*a=98:a[f]==98|*a==48&!f)?"%s":"%sb",a);}

TIO

Source Link
girobuz
  • 389
  • 2
  • 8

C, 209 203 bytes

main(b,c,f){c=b=0;char a[99]={0};gets(a);f=strlen(a)-3;a[f+1]=0;if(a[f]==98||(*a==48&&!f))b=1;if(*a=='-'&&a[1]==49&&f==1)a[1]=98,b=1;if(*a==49&&!f)*a=98,b=1;if(b){printf("%s",a);return;}printf("%sb",a);}