10101 - Bangla Numbers
Moderator: Board moderators
10101 Why WA!

----------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

Whats the wrong with my code? Why WA? Do u know?
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]
#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]
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
-
- New poster
- Posts: 14
- Joined: Fri Jul 05, 2002 7:04 pm
- Location: Bangladesh
- Contact:
I can
Contact me by my email address. I can help
with that problem....Rajib Mazumder

-
- Experienced poster
- Posts: 151
- Joined: Wed Aug 21, 2002 12:07 am
- Location: Seoul, Korea
- Contact:
Output for 0, 00, 000..
I just got AC and output for
0, 00, 000, and 0000 ... are all just 0.
No need to check about that
0, 00, 000, and 0000 ... are all just 0.
No need to check about that
-
- Experienced poster
- Posts: 147
- Joined: Fri Jun 13, 2003 10:46 pm
10101
could someone explain the rules behind Bangla Numbers? the question is quiet vague
Thank you
Bugz
Thank you
Bugz
Last edited by bugzpodder on Sat Sep 20, 2003 4:28 am, edited 1 time in total.
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
-
- Experienced poster
- Posts: 136
- Joined: Tue Apr 01, 2003 6:59 am
- Location: Jakarta, Indonesia
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!!

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!!


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.
-
- Experienced poster
- Posts: 147
- Joined: Fri Jun 13, 2003 10:46 pm
-
- Experienced poster
- Posts: 136
- Joined: Tue Apr 01, 2003 6:59 am
- Location: Jakarta, Indonesia
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
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

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)
Born from ashes - restarting counter of problems (800+ solved problems)