be calculated.php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



#include<iostream.h>
#include<string.h>
int i,j,x;
char a[50],n[15][10];
void f(int z);
void main()
{
	strcpy(n[2],"ribu");
	strcpy(n[3],"juta");
	strcpy(n[4],"milyar");
	strcpy(n[5],"triliun");
	cout<<"Masukan jumlah uang: ";
	cin>>a;
	cout<<"Senilai: ";
	for(i=0;i<50;i++)
		if(a[i]==NULL)
		{
			x=i;
			break;
		}
	for(i=0;i<x;i++)
	{
		if((a[i]!='0')&&((x-i==3)||((x-i)%3==0)))
		{
			if((a[i+1]!='0')||(a[i+2]!='0'))
			{
				if(a[i]=='1')
				{
					cout<<"seratus ";
				}
				else
				{
					f(a[i]);
					cout<<" ratus ";
				}
			}
			else
			{	
				if(a[i]=='1')
					cout<<"seratus "<<n[(x-
i+1)/3]<<" ";
				else
				{
					f(a[i]);
					cout<<" ratus "<<n[(x-i+1)/3]
<<" ";
				}
			}
		}
		else if((a[i]!='0')&&((x-i==2)||((x-i)%3==2)))
		{
			if(a[i+1]!='0')
			{
				if(a[i]=='1')
				{	
					if(a[i+1]=='0')
						cout<<"sepuluh ";
				}
				else
				{
					f(a[i]);
					cout<<" puluh ";
				}
			}
			else
			{
				if(a[i]=='1')
					cout<<"sepuluh "<<n[(x-
i+1)/3]<<" ";
				else
				{
					f(a[i]);
					cout<<" puluh "<<n[(x-i+1)/3]
<<" ";
				}
			}
		}
		else if((a[i]!='0')&&((x-i==1)||((x-i)%3==1)))
		{
			if(a[i-1]=='1')
			{
				if(a[i]=='1')			
	
					cout<<"se";
				else
				{
					f(a[i]);
					cout<<" ";
				}
				cout<<"belas "<<n[(x-i+2)/3]<<" ";
			}
			else
			{
				if((a[i]=='1')&&((x-i+2)/3==2)&&(a[i-
1]==0))
					cout<<"se"<<n[(x-i+2)/3]
<<" ";
				else
				{
					f(a[i]);
					cout<<" "<<n[(x-i+2)/3]<<" ";
				}
			}
		}
	}
	cout<<"rupiah\n";
}

void f(int z)
{
	if(z=='0')
		cout<<"";
	if(z=='1')
		cout<<"one";
	if(z=='2')
		cout<<"two";
	if(z=='3')
		cout<<"three";
	if(z=='4')
		cout<<"four";
	if(z=='5')
		cout<<"five";
	if(z=='6')
		cout<<"six";
	if(z=='7')
		cout<<"seven";
	if(z=='8')
		cout<<"eight";
	if(z=='9')
		cout<<"nine";
}

that my source in c++

can help me to make in php?

thx u ^^

example, if we input 54321

execute, so fifty four thousand three hundred twenty one rupiah 


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux