69,382
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include "string.h"
void main()
{
char *strwei[] = {
"分","角","元","拾","百","千",
"万","拾","百","千",
"亿","拾","百","千"};
char *strcc[10] = {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
/*
8700008700.00
8253048253.04
5987625987.62
*/
int *pnsz;
int nindex=0;
char sz_sm[20]={0};
sprintf(sz_sm,"8253048253.04");
pnsz = new int[strlen(sz_sm)-1];
for(int i=strlen(sz_sm)-1;i>-1;i--)
{
if(sz_sm[i]=='.')
continue;
pnsz[nindex++] = sz_sm[i]-48;
}
printf("%s转化为大写数字:\n",sz_sm);
char str[20];
for(i=nindex-1;i>-1;i--)
{
sprintf(str,"%s%s",strcc[pnsz[i]],strwei[i]);
printf("%s",str);
}
delete pnsz;
}
//自己在改改,有零的时候还需要改进的
#include <stdio.h>
#include <stdlib.h>
char *float2RMB(char *buf, const float fn)
{
if (buf == NULL)
return NULL;
sprintf(buf, "¥%.2f", (float)fn / 100);
return buf;
}
int main()
{
char c[20] = {0};
float data = 598762;
float2RMB(c, 598762);
printf("%s\n", c);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
char c[10];
char a[] = "812345";
float data = 0;
memset(c,'\0',sizeof(c));
sprintf(c,"%.2f",(atof(a) / 100.0));
printf("%s\n",c);
data = atof(a) / 100.0;
printf("%.2f\n",data);
return 0;
}
int num = 598762;
char str[20] = {0};
sprintf(str, "¥%4.2f", (float)num / 100);