#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char *mygcvt(double val)
{
char buf1[256];
static char buf2[256];
int prec = 1;
size_t len, maxlen = 0;
for (;;)
{
len
= strlen(gcvt
(val
, prec
, buf1
)); if (len <= maxlen)
break;
maxlen = len;
prec++;
}
return buf2;
}
int main(void)
{
printf("%s\n", mygcvt
(0.123)); printf("%s\n", mygcvt
(0.3333333333333333333333333333333333333333333)); return 0;
}
I2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKY2hhciAqbXlnY3Z0KGRvdWJsZSB2YWwpCnsKICAgIGNoYXIgYnVmMVsyNTZdOwogICAgc3RhdGljIGNoYXIgYnVmMlsyNTZdOwogICAgaW50IHByZWMgPSAxOwogICAgc2l6ZV90IGxlbiwgbWF4bGVuID0gMDsKICAgIGZvciAoOzspCiAgICB7CiAgICAgICAgbGVuID0gc3RybGVuKGdjdnQodmFsLCBwcmVjLCBidWYxKSk7CiAgICAgICAgaWYgKGxlbiA8PSBtYXhsZW4pCiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIG1heGxlbiA9IGxlbjsKICAgICAgICBzdHJjcHkoYnVmMiwgYnVmMSk7CiAgICAgICAgcHJlYysrOwogICAgfQogICAgcmV0dXJuIGJ1ZjI7Cn0KCmludCBtYWluKHZvaWQpCnsKICAgIHByaW50ZigiJXNcbiIsIG15Z2N2dCgwLjApKTsKICAgIHByaW50ZigiJXNcbiIsIG15Z2N2dCgxLjApKTsKICAgIHByaW50ZigiJXNcbiIsIG15Z2N2dCgwLjEpKTsKICAgIHByaW50ZigiJXNcbiIsIG15Z2N2dCgwLjEyMykpOwogICAgcHJpbnRmKCIlc1xuIiwgbXlnY3Z0KDAuMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMykpOwogICAgcmV0dXJuIDA7Cn0K