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

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,


An array of size 5X5 is given to us. The elements from 1 to 25 are to be inserted in the array, such that starting from a particular position for an element i, the next element i+1can be inserted only at the mentioned positions (u,v), and if these all positions are occupied then it returns giving a count of how many positions have been occupied in the array: (u,v) = (x+/-3 , y) (u,v) = (x , y+/-3) (u,v) = (x+/-2 , y+/-2). Example: if the starting element is 1 with the given positions (1,2), then next element 2 can be placed at any one of the positions marked with *. _ _ _ _ _ 1 _ _ _ * _ _ _ _ _ _ _ * _ _ * _ _ _ _

0 Answers   Nagarro,


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 that reverse the elements of an array in place.The function must accept only one pointer value and return void.

0 Answers   HCL, SRCASW,


write a program that can LOCATE and INSERT elements in array using c++ programming languages.

0 Answers  






Implement a command console for changing settings on a particular object. The command console should allow you to enter a string and will return the response (very similar to a terminal session). The commands are as follows: SET propertyname=newvalue will change the target object’s member named “propertyname” to have a value equal to “newvalue”. If the input value is incompatible (i.e. an int being set to a string), print out an appropriate error message. GET propertyname will print out the current value of the target object’s member named “propertyname”. GET * will print out a list of all target object members and their current values. The system should be extensible for future commands and should accept an arbitrary object, such that another developer could insert another object into the system and rely on the command console to get and set the properties correctly.

0 Answers   ABC, Guidance Software,


Complexity T(n) What is the time complexity T(n) of the following portions of code? For simplicity, you may assume that n is a power of 2. That is, n = 2k for some positive integer k. a) ? for (i = 1; i <= n; i++) { j = n; cout << i << ? ? j << ? ? << endl; } b) ? for (i = 0; i <= n; i += 2) { j = n; cout << i << ? ? j << ? ? << endl; } c) ? for (i = n; i >= 1; i = i/2) { j = n; cout << i << ? ? j << ? ? << endl; } d) for (i = 1; i <= n; i++) { j = n; while (j >= 0) { cout << i << ? ? j << ? ? << endl; j = j - 2; } }

0 Answers   Qatar University,


a program using one dimensional array that searches a number if it is found on the list of given input numbers given by the user and locate its exact location in the list.. ""EXAMPLE"" enter how many numbers to be inputted: 5 12 14 11 09 30 what number to search: 11 11 IS FOUND IN LOCATION 3 PLZZZ.. ELP ME...

3 Answers  


what is the use of using for loop as "for(;;)"?

5 Answers   Satyam,


develop a program to calculate and print body mass index for 200 employees

0 Answers   Jomo Kenyatta University,


Min-Max Write an algorithm that finds both the smallest and largest numbers in a list of n numbers and calculate its complexity T(n).

1 Answers   Infosys, Qatar University,


Code for Method of Handling Factorials of Any Size?

0 Answers  


Categories