10101 - Bangla Numbers

All about problems in Volume 101. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

zhangl
New poster
Posts: 4
Joined: Tue Nov 05, 2002 2:28 am
Location: China

Post by zhangl »

Can anybody help me with sending the program to me?
My E-mail is ctozlm@163.com.
Although being far far away,
Still I do do feel you.
Through the sky,
Across the ocean,
I hear

Taslim
New poster
Posts: 9
Joined: Sun Dec 08, 2002 11:47 am
Contact:

10101 Why WA!

Post by Taslim »

:(
----------INPUT----------
1.0
2.00
3.000
4.01
5.001
6.1000000000
7.100000000000000
----------OUTPUT--------
1. 0
2.
3.
4. 1
5. 1
6. 1 shata kuti
7. 1 kuti kuti

So whats the warng with my program :o [/b]

Taslim
New poster
Posts: 9
Joined: Sun Dec 08, 2002 11:47 am
Contact:

Whats the wrong with my code? Why WA? Do u know?

Post by Taslim »

Whats the wrong with my code? Why WA? Do u know?

#include<stdio.h>
#include<string.h>

void process(char string[])
{
int len,i;
len=strlen(string);
if(len==7)
{
if(string[0]=='0')
{
if(string[1]!='0')
printf("%c lakh ",string[1]);
}
else
printf("%c%c lakh ",string[0],string[1]);
if(string[2]=='0')
{
if(string[3]!='0')
printf("%c hajar ",string[3]);
}
else
printf("%c%c hajar ",string[2],string[3]);
if(string[4]=='0');
else
printf("%c shata ",string[4]);
if(string[5]=='0')
{
if(string[6]!='0')
printf("%c",string[6]);
}
else
printf("%c%c",string[5],string[6]);
return;
}

if(len==6)
{
if(string[0]=='0');
else
printf("%c lakh ",string[0]);
if(string[1]=='0')
{
if(string[2]!='0')
printf("%c hajar ",string[2]);
}
else
printf("%c%c hajar ",string[1],string[2]);
if(string[3]=='0');
else
printf("%c shata ",string[3]);
if(string[4]=='0')
{
if(string[5]!='0')
printf("%c",string[5]);
}
else
printf("%c%c",string[4],string[5]);
return;
}

if(len==5)
{
if(string[0]=='0')
{
if(string[1]!='0')
printf("%c hajar ",string[1]);
}
else
printf("%c%c hajar ",string[0],string[1]);
if(string[2]=='0');
else
printf("%c shata ",string[2]);
if(string[3]=='0')
{
if(string[4]!='0')
printf("%c",string[4]);
}
else
printf("%c%c",string[3],string[4]);
return;
}

if(len==4)
{
if(string[0]=='0');
else
printf("%c hajar ",string[0]);
if(string[1]=='0');
else
printf("%c shata ",string[1]);
if(string[2]=='0')
{
if(string[3]!='0')
printf("%c",string[3]);
}
else
printf("%c%c",string[2],string[3]);
return;
}
if(len==3)
{
if(string[0]=='0');
else
printf("%c shata ",string[0]);
if(string[1]=='0')
{
if(string[2]!='0')
printf("%c",string[2]);
}
else
printf("%c%c",string[1],string[2]);
return;
}
if(len==2)
{
if(string[0]=='0')
{
if(string[1]!='0')

printf("%c",string[1]);
}
else
printf("%c%c",string[0],string[1]);
return;
}
if(len==1)
{
if(string[0]=='0');
else
printf("%c",string[0]);
return;
}
}

void main()
{
char input[16],sub1[8],sub2[8];
int flag,len,i,temp,j;
long double count=0;
while(scanf("%s",input)!=EOF)
{
flag=0;

j=0;
count++;
printf("%.Lf. ",count);
len=strlen(input);
i=0;
if(len==1&& input[0]=='0')
printf("%c",input[0]);
if(len>14)
{
flag=1;
for(i=0;i<7;i++)
sub1=input[i+1];
sub1='\0';
temp=8;
for(i=0;i<7;i++)
{sub2=input[temp];temp++;}
sub2='\0';
}

if(len>7&&len<=14)
{
flag=2;
temp=len;
for(i=7;i>=0;i--)
{sub1=input[temp];temp--;}
sub1[8]='\0';
for(i=len-8;i>=0;i--)
{sub2=input[temp];temp--;}
sub2[len-7]='\0';
}
if(len<=7&&len!=0)
{flag=3;
for(i=0;i<len;i++)
sub1=input;
sub1='\0';}
if(flag==1)
{
printf("%c kuti ",input[0]);
process(sub1);
printf(" kuti ");
process(sub2);
}
if(flag==2)
{
process(sub2);
printf(" kuti ");
process(sub1);
}
if(flag==3)
process(sub1);
printf("\n");
}
}


[/cpp]

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

Why in case 2 and 3 you don't write output ?

Dominik

Taslim
New poster
Posts: 9
Joined: Sun Dec 08, 2002 11:47 am
Contact:

Post by Taslim »

Thanks for replay.......for case 2 my program print also...there was not the problem...I got AC :D but still Presentation Error.... :-? i am not geting whats the wrong in my out put....Thanks all.... :lol:

Rajib Mazumder
New poster
Posts: 14
Joined: Fri Jul 05, 2002 7:04 pm
Location: Bangladesh
Contact:

I can

Post by Rajib Mazumder »

Contact me by my email address. I can help :D with that problem....Rajib Mazumder

Whinii F.
Experienced poster
Posts: 151
Joined: Wed Aug 21, 2002 12:07 am
Location: Seoul, Korea
Contact:

Output for 0, 00, 000..

Post by Whinii F. »

I just got AC and output for

0, 00, 000, and 0000 ... are all just 0.
No need to check about that

turuthok
Experienced poster
Posts: 193
Joined: Thu Sep 19, 2002 6:39 am
Location: Indonesia
Contact:

Post by turuthok »

Ugh, I thought that the problem description explicitly says the input will be a positive number ... Got tripped on that ... :(

-turuthok-
The fear of the LORD is the beginning of knowledge (Proverbs 1:7).

bugzpodder
Experienced poster
Posts: 147
Joined: Fri Jun 13, 2003 10:46 pm

10101

Post by bugzpodder »

could someone explain the rules behind Bangla Numbers? the question is quiet vague

Thank you

Bugz
Last edited by bugzpodder on Sat Sep 20, 2003 4:28 am, edited 1 time in total.

anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:

Post by anupam »

parse the input with several if else. bugz
"Everything should be made simple, but not always simpler"

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

Think about dividing input numbers into parts of three digits ...

Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

Joseph Kurniawan
Experienced poster
Posts: 136
Joined: Tue Apr 01, 2003 6:59 am
Location: Jakarta, Indonesia

Post by Joseph Kurniawan »

just use hardcode!!
It's quite hard without hardcoding since contants are involved (shata, kuti, hajar, etc.).
I used 15 cases to solve this prob and got AC in first attempt. It's not a hard prob actually, but you have to be careful with the input!! :wink: :wink:
There are 3 things one need to be successful : motivation, ability and chance. And if you're a believer, make it four : God's will.

bugzpodder
Experienced poster
Posts: 147
Joined: Fri Jun 13, 2003 10:46 pm

Post by bugzpodder »

but what are the rules? what happens when its 1 kuti 1 lakh 0 hajar 1 shata

do i go: 1 kuti lakh shata?
or 1 kuti 1 lakh 1 shata?

what happens if its over 1 shata 1 khuti (10^10)? do i output 1 shata khuti?

do i treat this like english language? one hundred million and stuff?

Joseph Kurniawan
Experienced poster
Posts: 136
Joined: Tue Apr 01, 2003 6:59 am
Location: Jakarta, Indonesia

Post by Joseph Kurniawan »

1 kuti 1 lakh 0 hajar 1 shata = 1 kuti 1 lakh 1 shata
10^10 = 1 shata kuti
Hope this helps!! :wink: :wink: :wink:
There are 3 things one need to be successful : motivation, ability and chance. And if you're a believer, make it four : God's will.

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

It's not very hard to solve this problem without hardcoding :-)
I made it first time :-)
The clue is proper dividing number to part of three digits and use additional table with names of numbers (shata, kuti a.s.o.) ...

Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

Post Reply

Return to “Volume 101 (10100-10199)”