//challenge
#include<stdio.h>
#include<string.h>
int main()
{
int len,mod,i,j,k,loop,flag,flag7,flag5,flag2;
char str[100];
while(scanf(" %s",str) == 1)
{
len = strlen(str);
j=0;
while(str[j] == '0') //this loop is for eluminating leading 0's.
{
if(len == 1)//if the number is 0,then last digit will be kept.
break;
len--;
j++;
}
loop=(len+6)/7;
mod = len %7;
if(mod == 0)
mod = 7;
flag=0;
for(i=0; i<loop; i++)
{
flag7=flag5=flag2=0;
if(i) //kuti will not be printed in first time.
{
printf(" kuti");
flag =1;
}
if(mod == 7) //such if is used to determine the starting point of the number
{
mod--;
if(str[j] != '0')
{
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c",str[j]);
flag7 = 1;
}
j++;
}
if(mod == 6)
{
mod --;
if(str[j] != '0' || flag7) {
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c lakh",str[j]);
j++;
flag =1;
}
}
if(mod == 5)
{
mod--;
if(str[j] != '0')
{
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c",str[j]);
flag5 = 1;
}
j++;
}
if(mod == 4)
{
mod --;
if(str[j] != '0' || flag5) {
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c hajar",str[j]);
}
j++;
flag =1;
}
if(mod == 3)
{
mod--;
if(str[j] != '0') {
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c shata",str[j]);
flag =1;
}
j++;
}
if(mod == 2)
{
mod--;
if(str[j] != '0')
{
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c",str[j]);
flag2=1;
}
j++;
}
if(mod == 1)
{
mod = 7;
if(flag2 ==1 || str[j] != '0' || len == 1)
{
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c",str[j]);
}
j++;
}
if(i && loop==(i-1)) { //last koti will print.
printf(" kuti");
flag = 1;
}
}
putchar('\n');
}
return main();
}
#include<stdio.h>
#include<string.h>
int main()
{
int len,mod,i,j,k,loop,flag,flag7,flag5,flag2;
char str[100];
while(scanf(" %s",str) == 1)
{
len = strlen(str);
j=0;
while(str[j] == '0') //this loop is for eluminating leading 0's.
{
if(len == 1)//if the number is 0,then last digit will be kept.
break;
len--;
j++;
}
loop=(len+6)/7;
mod = len %7;
if(mod == 0)
mod = 7;
flag=0;
for(i=0; i<loop; i++)
{
flag7=flag5=flag2=0;
if(i) //kuti will not be printed in first time.
{
printf(" kuti");
flag =1;
}
if(mod == 7) //such if is used to determine the starting point of the number
{
mod--;
if(str[j] != '0')
{
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c",str[j]);
flag7 = 1;
}
j++;
}
if(mod == 6)
{
mod --;
if(str[j] != '0' || flag7) {
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c lakh",str[j]);
j++;
flag =1;
}
}
if(mod == 5)
{
mod--;
if(str[j] != '0')
{
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c",str[j]);
flag5 = 1;
}
j++;
}
if(mod == 4)
{
mod --;
if(str[j] != '0' || flag5) {
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c hajar",str[j]);
}
j++;
flag =1;
}
if(mod == 3)
{
mod--;
if(str[j] != '0') {
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c shata",str[j]);
flag =1;
}
j++;
}
if(mod == 2)
{
mod--;
if(str[j] != '0')
{
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c",str[j]);
flag2=1;
}
j++;
}
if(mod == 1)
{
mod = 7;
if(flag2 ==1 || str[j] != '0' || len == 1)
{
if(flag)
{
putchar(' ');
flag=0;
}
printf("%c",str[j]);
}
j++;
}
if(i && loop==(i-1)) { //last koti will print.
printf(" kuti");
flag = 1;
}
}
putchar('\n');
}
return main();
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন