//Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
// same ids are connected.
// prefix 的格式要求是 acm-[一级标题编号].[二级标题编号][该代码片段的英文简称]
// description 的格式要求是 "插入 [该代码片段的中文名]"

{
    "n进制 转 m进制": {
        "prefix": "acm-1.5n_to_ten",
        "body": [
            "#include<cstdio>",
            "const int N=1e5+3;",
            "int n,m,x,tmp,ansl;char a[N],ans[N];",
            "inline int n_to_ten(){",
            "\tint x=0;",
            "\tfor(int i=0;a[i];++i){",
            "        x*=n;",
            "        if (a[i]>='A'&&a[i]<='F')x+=(a[i]-'A'+10);",
            "        else x+=(a[i]-'0');",
            "   }",
            "   return x;",
            "}",
            "inline void ten_to_m(){",
            "\tdo{",
            "\t\ttmp=x%m;",
            "\t\tif(tmp<10)ans[++ansl]='0'+tmp;",
            "\t\telse ans[++ansl]='A'+tmp-10;",
            "\t\tx/=m;",
            "\t\t",
            "\t}while(x);",
            "}",
            "int main(){",
            "   scanf(\"%d%s%d\",&n,a,&m);",
            "   x=n_to_ten();",
            "   ten_to_m();",
            "   for(int i=ansl;i;--i)printf(\"%c\",ans[i]);puts(\"\");",
            "}",
            ""
        ],
        "description": "插入 n进制 转 m进制"
    }
}