2. Counting in Lojban, an artificial language developed
over the last fourty years, is easier than in most languages
The numbers from zero to nine are:
0 no
1 pa
2 re
3 ci
4 vo
5 mk
6 xa
7 ze
8 bi
9 so
Larger numbers are created by gluing the digit togather.
For Examle 123 is pareci
Write a program that reads in a lojban string(representing
a no less than or equal to 1,000,000) and output it in
numbers.

Answer Posted / simi

In java We can do the same as
int getIntValueForString(Stirng str){
if("AB".equals(str))return 0;
.
.
.
.
.
if("rs".equals(str))return 9;
}
public static void main(Stirng [args]){
//get the String as an input from the user
//Call the method to get the int
String intValue = getIntValueForLojbanString(inputString , 0);
}
Stirng getIntValueForLojbanString(String inputString ,
String Value){
int i=0;
String intValue = new intvalue();
if(inputString != null || inputString.length()==0) return
intValue;
else
{
if(Value !=null)
intValue= Value +
getIntValueForString(inputString.chatAt[i]+inputString.chatAt[i+1]).toString();

else
intValue =
getIntValueForString(inputString.chatAt[i]+inputString.chatAt[i+1]).toString();

if(inputString.length()>2)
getIntValueForLojbanString(inputString.subString(i+3) ,
intValue);}
}
}

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is the difference between the expression '++a' and 'a++'?

627


What is function what are the types of function?

560


Which is best linux os?

565


Write a program to swap two numbers without using third variable?

815


to find the closest pair

1823






write a proram to reverse the string using switch case?

2469


What are identifiers c?

566


What is realloc in c?

581


What is LINKED LIST? How can you access the last element in a linked list?

633


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

644


Write a program to implement queue.

666


Can you write the function prototype, definition and mention the other requirements.

662


What is void pointers in c?

590


Why doesnt that code work?

601


Explain null pointer.

622