C + + lowercase digits to uppercase digits

Source: Internet
Author: User
Tags lowercase printf

#include <stdio.h>
void Main ()
{
Double x,y;
Char *ch[]={"0", "one", "II", "three", "Restaurant", "WU", "Lu", "Qi", "ba", "Nine"};
Char *ch1[]={"Pick Up", "Bai", "Thousand", "Million", "Pick Up", "Bai", "thousand", "billion"};
Char num[256];
Long i,n,j,m,y1;
printf ("Input:");
scanf ("%lf", &x);
n= (long) x;/* integral part/
y=x-n;/* to the small number of parts
for (i=0;n!=0;i++)
{
Num[i]= (char) (N%10);
n/=10;
}
M=i;
Num[i]= '. ';
for (y=y*10; (long) (y) *10);)/* If the decimal place or number (not 0) the loop continues * *
y*=10;/* decimal converts to integers such as 0.11111 to 11111.00...*/
y1= (long) y;
for (i=m+1;y1!=0;i++)
{num[i]= (char) (Y1%10);
Y1=Y1/10;} * * Take the numbers on you
for (n=0;; n++)
{
if (num[n]== '. ')
{
for (j=n-1;j>=0;j--)/* Judge whether is million, billion bit. If you judge whether it is 0 then do not output 0. * *
{
if (m<=5)
if (m==5&& (int) num[j]==0)
;
Else
printf ("%s", ch[(int) num[j]);/* Output Uppercase one ... */
Else
if (m%4==0&& (int) num[j]==0)
;
Else
printf ("%s", ch[(int) num[j]]);
if (m>=2)
{printf ("%s", ch1[m-2]);/* Output pick up. If you have 2 digits to the output/
m=m--;}
}
printf ("point");
Break
}
}
for (i=i-1;num[i]!= '. ') i--)
printf ("%s", ch[(int) num[i]);//Output Decimal Part * *
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.