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



Counting in Lojban, an artificial language developed over the last fourty years, is easier than in..

Answer / ashwin murali

#include<iostream>
using namespace std;
#include<cstring>

int main(){
string str="parecisobixa";
int l;
l=str.length();
cout<<l<<endl;
for(int i=0;i<=l;i=i+2){
string sub=str.substr(i,2);


if(sub=="pa"){cout<<1; }
if(sub=="re"){cout<<2;}
if(sub=="ci"){cout<<3;}
if(sub=="vo"){cout<<4;}
if(sub=="mk"){cout<<5;}
if(sub=="xa"){cout<<6;}
if(sub=="ze"){cout<<7;}
if(sub=="bi"){cout<<8;}
if(sub=="so"){cout<<9;}
}

return 0;
}

Is This Answer Correct ?    7 Yes 1 No

Counting in Lojban, an artificial language developed over the last fourty years, is easier than in..

Answer / manoj pathak

#include<iostream.h>
#include<conio.h>

void main()
{
int i=0,k;
char ph,ch[10];
clrscr();
while(ph!='\r')
{
ph=getche();
ch[i]=ph;
i++;
}
cout<<endl<<endl<<endl;
for(k=0;k<i;)
{
if(ch[k]=='n')
{
if(ch[k+1]=='o')
cout<<"0";
else
{
clrscr();
cout<<"Entered String is not code" ;
break;
}
}
if(ch[k]=='p')
{
if(ch[k+1]=='a')
cout<<"1";
else
{
clrscr();
cout<<"Entered String is not code" ;
break;
}
}

if(ch[k]=='r')
{
if(ch[k+1]=='e')
cout<<"2";
else
{
clrscr();
cout<<"Entered String is not code" ;
break;
}
}

if(ch[k]=='c')
{
if(ch[k+1]=='i')
cout<<"3";
else
{
clrscr();
cout<<"Entered String is not code" ;
break;
}
}

if(ch[k]=='v')
{
if(ch[k+1]=='o')
cout<<"4";
else
{
clrscr();
cout<<"Entered String is not code" ;
break;
}
}

if(ch[k]=='m')
{
if(ch[k+1]=='k')
cout<<"5";
else
{
clrscr();
cout<<"Entered String is not code" ;
break;
}
}

if(ch[k]=='x')
{
if(ch[k+1]=='a')
cout<<"6";
else
{
clrscr();
cout<<"Entered String is not code" ;
break;
}
}

if(ch[k]=='z')
{
if(ch[k+1]=='e')
cout<<"7";
else
{
clrscr();
cout<<"Entered String is not code" ;
break;
}
}

if(ch[k]=='b')
{
if(ch[k+1]=='i')
cout<<"8";
else
{
clrscr();
cout<<"Entered String is not code" ;
break;
}
}

if(ch[k]=='s')
{
if(ch[k+1]=='o')
cout<<"9";
else
{
clrscr();
cout<<"Entered String is not code" ;
break;
}
}

k=k+2;
}
getch();
}

Is This Answer Correct ?    4 Yes 4 No

Counting in Lojban, an artificial language developed over the last fourty years, is easier than in..

Answer / iti tomar

string [] q = new string
[10];//"no","pa","re","ci","vo","mk","xa","ze","bi","so"];
q[0] = "no";
q[1] = "pa";
q[2] = "re";
q[3] = "no";
q[4] = "ci";
q[5] = "vo";
q[6] = "mk";
q[7] = "xa";
q[8] = "ze";
q[9] = "bi";
int alen = q.Length;
//q[0] = "so";
int ln;
string result= string.Empty;
int res;
string str = (string)TextBox1.Text;
ln = str.Length;
if (ln % 2 != 0)
{
Response.Write("Invalid number");
}
else
{

string r;
for (int i = 0; i <= ln-2; i = i + 2)
{
for (int ale = 0; ale < alen; ale++)

if (str.Substring(i,2) == q[ale])
{

result = result + ale.ToString();
//i++;
//i++;
}


}

TextBox2.Text = result;

}

}
}

Is This Answer Correct ?    0 Yes 2 No

Counting in Lojban, an artificial language developed over the last fourty years, is easier than in..

Answer / sudha

#include<conio.h>
#include<iostream>

int main()
{
char *q[] = {"no", "pa", "re", "ci", "vo", "mk", "xa",
"ze", "bi", "so"};
char *lojban, num[3];
int i,j,k;

cout << "\nEnter the value in lojban\n" ;
cin >> lojban;

i=0;
while(lojban[i++]);

num[2] = '\0';
cout << "The number is \n";

for(j=0; j<i-1; j=j+2)
{
k = 0;
strncpy(num, lojban+j, 2);

do
{
if (k == 11) { cout << "<Invalid Entry>";
break;}
}while(strcmp(num,q[k++]));

if (k != 11)
cout << k-1;

}

getch();
return(0);
}

Is This Answer Correct ?    1 Yes 5 No

Post New Answer

More C++ Code Interview Questions

how to diplay a external image of output on winxp by using c & c++,

0 Answers  


Write a &#61521;(n) algorithm that sorts n distinct integers, ranging in size between 1 and kn inclusive, where k is a constant positive integer. (Hint: Use a kn-element array.)

0 Answers  


write a function -oriented program that generates the Fibonacci, the current numbers of n(as input) and display them (series). In Fibonacci, the current third number is the sum of the previous number.

3 Answers  


Where now stands that small knot of villages known as the Endians, a mighty forest once stood. Indeed, legand has it that you could have stoodon the edge of the wood and seen it stretch out for miles, were it not for the trees getting in the way. In one section of the forest, the trees stood in a row and were of hight from 1 to n, each hight occurring once and once only. A tree was only visible if there were no higher trees before it in the row. For example, if the heights were 324165, the only visible trees would have been those of height 3,4 & 6. Write a Program that takes an array of integers representing the heights of the trees in the row as input and prints the list of the visible trees.

2 Answers   ABC, Nagarro,


can we declare an object of a class in another class?(assume both class as public classes)

1 Answers   Microsoft,






Write a function- oriented to convert the input dollar(s) into its equivalent peso. Assume that one dollar is equivalent to 51.60

1 Answers  


write a program in c++ to scramble a bmp image file using a scramble key 0x7c and an XOR logic. print out the original image, the scrambled image and the program. Note: the first 24bytes of a bmp file contain the header information of the file.

1 Answers  


readers and writers problem

1 Answers   Cognizant,


how to take time as input in the format (12:02:13) from user so that controls remains between these columns?

0 Answers  


how to find out the maximum number out of the three inputs.

6 Answers   ABC, Apple, C3I, HP, TCS,


write a program that can locate elements in array.

1 Answers  


write a program that calculate the volume of cylinder after user enters radius and height and show the algorithm used

1 Answers   Jomo Kenyatta University,


Categories