c中數字轉貨幣
Ⅰ CCNY數字貨幣能兌換人民幣嗎
不用兌換,它本身就是人民幣的數字形態。是法定貨幣,強制流通。
Ⅱ 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;
}
Ⅲ 貨幣轉換c語言編程
#include<stdio.h>
int main()
{
int x;
printf("which currency do u want to convert?\n");
printf("1:Japanese Yen\n");
printf("2:British Pound:enter 2\n");
printf("3:Euro:enter 3\n");
printf("4:American Dollar:enter 4\n");
printf("5:Canadian Dollar:enter 5\n");
printf("6:Australian Dollar:enter 6\n");
scanf("%d",&x);
switch(x)
{
case 1: printf("13.4126");break;
case 2: printf("0.10009");break;
case 3: printf("0.230693");break;
case 4: printf("0.146364");break;
case 5: printf("0.150878");break;
case 6: printf("0.172603");break;
default : printf("error");
}
}
Ⅳ 如何實現實時輸入數字自動轉換為貨幣形式
呵呵,這個簡單,用JavaScript的onfocus和onblur事件就可以了,前者是焦點集中事件,後者是焦點離開事件,代碼如下:
<html>
<head>
<title>Made By tjoy7d</title>
</head>
<SCRIPT LANGUAGE="JavaScript">
<!--
//得到貨幣形式的數值
function getCurrency(s){
res = Number(s.value).toFixed(2)
return res
}
//得到兩個數的乘積
function getMul(){
res = Number(a.value)*Number(b.value)
res = Number(res).toFixed(2)
return res
}
//-->
</SCRIPT>
數量: <input id=a type=text><br>
單價: <input id=b type=text onblur="this.value=getCurrency(b)"><br>
乘積結果: <input id=c type=text onfocus="this.value=getMul()"><br>
可能不是很符合你的要求,不過你還可以改進一下:)
Ⅳ C#將輸入的數字轉換為大寫漢字,用於貨幣,求教!
直接調chang()這個方法就行
string ht1 = chang(Convert.ToDouble(234.45));
public static string chang(double Digital)
{
//將小寫金額轉換成大寫金額
String[] MyScale = { "分", "角", "圓", "拾", "佰", "仟", "萬", "拾", "佰", "仟", "億", "拾", "佰", "仟", "兆", "拾", "佰", "仟" };
String[] MyBase = { "零", "壹", "貳", "叄", "肆", "伍", "陸", "柒", "捌", "玖" };
String moneyStr = "";
bool isPoint = false;
string moneyDigital = Digital.ToString();
if (moneyDigital.IndexOf(".") != -1)
{
moneyDigital = moneyDigital.Remove(moneyDigital.IndexOf("."), 1);
isPoint = true;
}
for (int i = moneyDigital.Length; i > 0; i--)
{
int MyData = Convert.ToInt16(moneyDigital[moneyDigital.Length - i].ToString());
moneyStr += MyBase[MyData];
if (isPoint == true)
{
moneyStr += MyScale[i - 1];
}
else
{
moneyStr += MyScale[i + 1];
}
}
while (moneyStr.Contains("零零"))
moneyStr = moneyStr.Replace("零零", "零");
moneyStr = moneyStr.Replace("零億", "億");
moneyStr = moneyStr.Replace("億萬", "億");
moneyStr = moneyStr.Replace("零萬", "萬");
moneyStr = moneyStr.Replace("零仟", "零");
moneyStr = moneyStr.Replace("零佰", "零");
moneyStr = moneyStr.Replace("零拾", "零");
while (moneyStr.Contains("零零"))
moneyStr = moneyStr.Replace("零零", "零");
moneyStr = moneyStr.Replace("零圓", "圓");
moneyStr = moneyStr.Replace("零角", "");
moneyStr = moneyStr.Replace("零分", "");
moneyStr = moneyStr + "整";
return moneyStr;
}
Ⅵ 幫個忙寫個C語言程序,關於把數字轉換成人民幣大寫
首先,取位數,分出來十,百,千什麼的
把錢數分別存出來,可以存到數組里,然後從高位取,如果高位都是0,就過去
到第一個不是0的開始,對應的輸出大寫漢字一,二,三....
輸出一個,在後面加上單位,就是十,百千那些
我就不給你寫了
不是很難的
好好想想吧
Ⅶ c#中的貨幣類型如何轉換
System.Convert.ToDouble("12354465").ToString("c")
Ⅷ c#將數字轉換為貨幣格式
int i = 60000;
string d=i.ToString("c");
Ⅸ C語言將一串數字字元12345678變成貨幣形式$12,345,678
辦法很多,提供一個比較低級的。注意原字串空間要大到能放下修改後的字串。
//#include"stdafx.h"//Ifthevc++6.0,withthisline.
#include"stdio.h"
#include"string.h"
intmain(void){
chara[20]="12345678",t[20],ln;
for(ln=strlen(a)-3;ln>0;ln-=3){
strcpy(a+ln+1,strcpy(t,a+ln));
a[ln]=',';
}
strcpy(a+1,strcpy(t,a));
*a='$';
printf("%s ",a);
return0;
}
Ⅹ c輸入一個整數,並以貨幣格式輸出
其實不難的嘛,程序如下:
#include <stdio.h>
#include <string.h>
#define N 100
int main(void)
{
char a[N]={0},b[N]={0};
int len,cnt,i,j;
printf("請輸入一個整數:");
scanf("%s",a);
b[0]='$';
len=strlen(a);
cnt=len%3;
for(i=0,j=1;i<len;i++)
{
if(cnt==0)
{
b[j++]=',';
cnt=3;
}
b[j++]=a[i];
cnt--;
}
printf("貨幣格式為:%s\n",b);
}