d2hz.c

来自「数字串转中文大写的小代码段」· C语言 代码 · 共 53 行

C
53
字号
#include	<stdio.h>#include	<string.h>#include	"supp.h"void	str2str (char   *s){	char	*h, *t;	int	d, c;	int	utype1, utype2, dtype;	int	slen;	if (!s) {
		printf ("零\n");
		return;
	}

	slen = strlen (s);	h = s;	t = s+slen-1;	d = utype1 = utype2 = dtype = 0;	for (;t>=h;t--) {		c = (*t) - '0';		if (utype2>0 && utype1 ==0)			push (utype2, 2);		if (c)			push (utype1, 1);		push (c, 0);		d++;		utype1 = d % 4;		utype2 = (d / 4) % 3;		if (d > 8 && utype2 ==0)		    utype2++;	}		dump();	return;}
void longtostr (long n)
{
	char	s[12];

	sprintf (s, "%ld", n);
	str2str (s);

	return;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?