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.
Answers were Sorted based on User's Feedback
Answer / ts
U can easily do this in c i am writing a code you just make its function by your self.Its easy one
#include<stdio.h>
main()
{
int i=0;
char ptr,d;
char c[20];
do
{
printf(" \n Enter the lujban String whose equivalent number is to be printed \n");
scanf("%s",c);
while(c[i]!='\0')
{
switch(c[i])
{
case'n':printf("0");
break;
case 'p':printf("1");
break;
case 'r':printf("2");
break;
case 'c':printf("3");
break;
case 'v':printf("4");
break;
case 'm':printf("5");
break;
case 'x':printf("6");
break;
case 'z':printf("7");
break;
case 'b':printf("8");
break;
case 's':printf("9");
break;
}
i++;
}
printf(" \nDo you want to continue(Y/N)");
d=getche();
}
while(d=='y'||d=='Y');
}
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / abdur rab
#include <stdio.h>
int decimal_from_logban ( char* cp_logban )
{
if ( !strcmp ( cp_logban, "no" ) ) return 0;
if ( !strcmp ( cp_logban, "pa" ) ) return 1;
if ( !strcmp ( cp_logban, "re" ) ) return 2;
if ( !strcmp ( cp_logban, "ci" ) ) return 3;
if ( !strcmp ( cp_logban, "vo" ) ) return 4;
if ( !strcmp ( cp_logban, "mk" ) ) return 5;
if ( !strcmp ( cp_logban, "xa" ) ) return 6;
if ( !strcmp ( cp_logban, "ze" ) ) return 7;
if ( !strcmp ( cp_logban, "bi" ) ) return 8;
if ( !strcmp ( cp_logban, "so" ) ) return 9;
}
void logban_2_decimal ( char* _lojban, int* _decimal )
{
char lojban_array [3];
memset ( lojban_array, '\0', 3 );
if ( ( NULL != _lojban ) && ( '\0' != *( _lojban +
2 ) ) ) {
logban_2_decimal ( _lojban + 2, _decimal +
1 );
strncpy ( lojban_array, _lojban, 2 );
*_decimal = decimal_from_logban (
lojban_array );
} else {
strncpy ( lojban_array, _lojban, 2 );
*_decimal = decimal_from_logban (
lojban_array );
}
}
int main ( int argc, char* argv [] )
{
char number_lojban [] = {"sopareci"};
int number_decimal [8];
int i = 0;
logban_2_decimal ( number_lojban, number_decimal ) ;
printf ( "\nLojban :%s", number_lojban );
printf ( "\nDecimal :" );
for ( i = 0; i < ( strlen ( number_lojban ) / 2 );
i++ )
printf ("%d", number_decimal [ i ] );
return ( 0 );
}
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / 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 |
How can I discover how many arguments a function was actually called with?
Table of Sudoku n*n
Can a pointer be static?
How can you find the day of the week given the date?
Is main() is used in the program,,see below example? void main() { int i; for(i=0;i<10;i++) main(); } Then what is the output of the program?
who is the founder of c
19 Answers College School Exams Tests, HP,
Hi Every one......... Please Any body give me the answer for my question. Is it possible to print the word "PRINT F", without using printf() statement in C-Language.
How to reverse alternate words in a given line of string For Eg: my name is narasimha output : my eman is ahmisaran
#include <stdio.h> void main() { int i=-1,j=1,k,l; k=!i&&j; l=!i||j; printf ("%d%d",k,l) ; }
How important is structure in life?
could u able to tell about suresoft technical session
How can I remove the trailing spaces from a string?