c语言小写金额转换大写金额
⑴ c语言小写转大写怎么编
#include <含信stdio.h> void main() { char a,b; printf("请输入一个小写字母"); scanf("%c"中局,&a); b=a-32; printf("%c",b); } 小写转大写是要-的卖老让,a的键控代码97,A是65 最简单易懂又不易错的方法:b=a-'a'+'A'
⑵ C语言编程:用指针编程序实现,输入一个人民币小写金额值,转化为大写金额值输出。
#include "stdafx.h"
#include<stdio.h>
#define NUM1 1
#define NUM2 2
#define NUM3 3
#define NUM4 4
#define NUM5 5
#define NUM6 6
#define NUM7 7
#define NUM8 8
#define NUM9 9
#define NUM 10
#define NUM10 11
#define NUM100 12
#define NUM1000 13
#define NUM10000 14
#define NUM100000 15
#define NUM1000000 16
#define NUM10000000 17
#define NUM100000000 18
#define NUM1000000000 19
#define NUM10000000000 20
void show_num(int *save,int count)
{
int i=count;
while(i>=0)
{
switch(save[i])
{
case 1:
printf("一");
break;
case 2:
printf("睁链燃二");
break;
case 3:
printf("三");
break;
case 4:
printf("四");
break;
case 5:
printf("五");
break;
case 6:
printf("六");
break;
case 7:
printf("七");
break;
case 8:
printf("八");
break;
case 9:
printf("九");
break;
case NUM10:
printf("十");
break;
case NUM100:
printf("百");
break;
case NUM1000:
printf("千");
break;
case NUM10000:
printf("万");
break;
case NUM100000:
printf("十");
break;
case NUM1000000:
printf("百");
break;
case NUM10000000:
printf("千"悉虚);
break;
case NUM100000000:
printf("亿");
break;
default:
break;
}
i--;
}
printf("\n");
}
int main()
{
long int num=0,i=0;
int save[20]={0};
printf("请输入要大唤哪写的数值:");
scanf("%d",&num);
while(num)
{
save[i]=num%10;
num=num/10;
save[i+1]=NUM10+i/2;
i+=2;
}
show_num(save,i-2);
return 0;
}
如果有需要,自己太添加,就在那个switch里面,还有宏,
但是不能超过你定义的类型的最大值,否则会出错哦
汉字部分自己改把
⑶ C语言 小写数字转换大写汉字
应该是小写字母转大写字母。
#include<stdio.h>
char*toUpper(char*src)
{
inti=-1;
while(src[++i])
if(src[i]>='a'&&src[i]<='z')//如果是小写字符册橡耐,减去32就是大小写了
如行src[i]-=32;
returnsrc;
}
intmain()
{
州春charp[]="acsavh4516;';gbasff";
printf("relust=%s ",toUpper(p));
return0;
}
⑷ c++将小写金额转化为大写金额,以及日期格式转化
#pragma
warning(disable:4786)
#include
<string>
#include
<stdio.h>
#include
<iostream>
#include
<vector>
using
std::vector;
using
std::string;
using
std::cout;
using
std::cin;
using
std::endl;
string
ConvertMoney(double
dNum)
{
string
strResult;//要返回的字符串
char
c_Digit[20];//c风格的字符数组
string
strDigit;//输入的数字字符串
int
iLength
=
0;//输入的双精度数的长度
int
iAddZero
=
0;//加零标志
int
iDigit
=
0;//取出的数字
string
str1[]
=
{"分","角","元","拾","佰","仟","万",
"拾","佰","仟","亿","拾","佰","仟","万","拾","佰","仟"};
string
str2[]
=
{"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
vector<string>
strUnit(str1,str1
+
18);//初始化向量
vector<string>
strUpperNum(str2,str2
+
10);
sprintf(c_Digit,"%.0f",dNum*100);//将数字串换成c风格的数组
strDigit
=
c_Digit;//将字符数组的内容赋值给string变量
iLength
=
strDigit.length();//取得字符串的长度
if
(iLength
>
15
||
iLength
<
0)//如果输入的数字超歼清出double类型数据的长度的话返回“error“
return
"Error";
for
(int
i
=
0;
i
<
iLength;
i++)
{//将字符串逐位处理
iDigit
=
atoi(strDigit.substr(i,1).c_str());
if
(iDigit
==
0)//如果当前位为零,则将加零标志+1
iAddZero++;
else
{
if
(iAddZero
>
0)//如果当前为不为0,且加0标志大于0
strResult
+=
"零";//则在字符串中加入“零“
strResult
+=
strUpperNum[iDigit];
iAddZero
=
0;
}
//该位不为0||元位||亿位||万位
if
((iDigit
!=
0)
||
(iLength
-
i
==
3)
||
(iLength
-
i
==
11)||((iLength
-
i
+
1)%8
==
0
&&
(iAddZero
<
4)))
strResult
+=
strUnit[iLength
-
i
-
1];
}
if
(strDigit.substr(strDigit.length()
-
2,2)
==
"00")
strResult
+=
"整";
return
strResult;
}
int
main()
{
double
dLowerRMB
=
0.0;
cout
<<
"请穗碰输入要转换的人民币金额!"
<<
endl;
cin
>>
dLowerRMB;
cout
<<
"-------------------------------------------------"
<<
endl;
cout
<<
"您要转换的人民币小写金额为
"
<<
"\n"
<<
dLowerRMB
<<
endl;
cout
<<
"-------------------------------------------------"
<<
endl;
string
strUpperRMB
=
ConvertMoney(dLowerRMB);
cout
<<
"大写金额为猜改谈"
<<
"\n"
<<
strUpperRMB
<<
endl;
cout
<<
"-------------------------------------------------"
<<
endl;
return
0;
}
⑸ C语言编程:数字金额转换为中文大写金额
#include<stdio.h>
#include<conio.h>
main()
{
int i,size=0;
char s[11];
printf("请输入金额:");
scanf("%s",s);
printf("次数的中文大写金额为:\n\n");
printf("佰\t拾\t万\t仟\t佰\t拾消孝\t元\t角\t分\n");
for(i=0;s[i]!='\0';i++)
{
if(s[i]=='.') break;
size++;
}
for(i=0;i<(7-size);i++)
{
printf(" \t");
}
for(i=0;s[i]!='\0';i++)
{
switch(s[i])
{
case '0':printf("零\t");break;
case '1':printf("壹\t"拿蔽稿);break;
case '2':printf("贰\t");break;
case '3':printf("叁\并扒t");break;
case '4':printf("肆\t");break;
case '5':printf("伍\t");break;
case '6':printf("陆\t");break;
case '7':printf("柒\t");break;
case '8':printf("捌\t");break;
case '9':printf("玖\t");break;
}
}
getch();
}
结果:(可能不是你想要的,如果不是你想要的结果,你能给我你想要的结果吗?)
⑹ c语言编写一个能够将人民币小写金额自动转化为大写写金额的程序写出程序语句
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
string ConvertMoneyCaps(long double moneySum)
{
long int temp_i = (long int)moneySum; /**//* 整数部分 */
float temp_f = moneySum - temp_i; /**//* 小数部分 */
int digit = 0, i, j, k, num_i;
string money("");
char num[20], *p;
char name[][3] = {"元","拾","佰","仟","万","亿"};
char numchar[][3] = {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
ltoa(temp_i, num, 10); /**//* 整数部分转换成字符串后在搏毕慎处理 */
p = num;
digit = strlen(num); /**//* 整数部分位数 */
/**//*--------处理整数部分 start--------*/
for(i = 1; i <= digit; i ++)
{
k = (digit - i) % 4;
if(isdigit(*p))
{
num_i = *p & 0xF; /**//* 把字符转换成数字,比如 '0'-> 0,'1' ->基敬 1*/
/**//*--------转换数字开始---------*/
if(num_i)
{
money = money+ numchar[num_i];
}
else
{
if(k && (*(p + 1) &0xF))
money += "零";
}
/**//*--------转换数字结束-------*/
/**//*---------添加计数单位开始----*/
if(k)
{
if(num_i)
money = money + name[k];
}
else
{
j = digit - i;
if(j)
money = money + name[j/4 + 3];
else
money += "元";
}
/**//*--------添加计数单位结束数并--------*/
p++;
}
else
{
money = "遇到非数字退出!";
return money;
}
}
/**//*--------处理整数部分 End --------*/
/**//*--------处理小数部分 start--------*/
if(temp_f > 0.01)
{
if((int)(temp_f*10)) money = money + numchar[(int)(temp_f*10)] + "角";
if((int)(temp_f*100)%10) money = money + numchar[(int)(temp_f*100)%10] + "分";
}
/**//*--------处理小数部分 End--------*/
money += "整";
return money;
}
int main()
{
long double x = 33.20;
cout << "please input the money:";
cin >> x;
cout << "Convert Money Caps:";
string money = ConvertMoneyCaps(x);
cout << money <<endl;
return 0;
}