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 / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a program to calculate the amount of investment after a period n years if the principal investors was p and interest is calculated using compound interest,formular=a=p(1+r)^n

2364


Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?

7330


find level of following tree (state, parent) " J,D I,D H,C E,B F,B G,C B,A D,A C,A A,& K,E L,E L,F M,F N,G O,H P,I P,H Q,I R,J S,K U,P T,L

2002


How can I Draw an ellipse in 3d space and color it by using graph3d?

2130


write a program that reverses the input number of n.Formulate an equation to come up with the answer.

7028






write a program to perform generic sort in arrays?

2619


Teta-Omeg-Big-Oh Show that f(n) = n2 + 3n3 is ;(n3).

3186


3. Program to find the Sum of give series. a. (1)+(1+2)+(1+2+3)+(1+2+3+4)+……………………………….. b. 1/1+1/9+1/25+1/49+……………...

4349


Ask the user to input three positive integers M, N and q. Make the 2 dimensional array of integers with size MxN, where all the elements of I (I = 1,…,M) line will be members of geometrical progression with first element equal to the number of line (I) and denominator q.

3389


1+1/2!+1/3!+...+1/n!

1939


write a program that prompt the user to enter his height and weight,then calculate the body mass index and show the algorithm used

4300


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

3431


write a program using 2 D that searches a number and display the number of items 12 inputs values input 15,20, 13, 30, 38, 40,16, 18, 20 ,18 ,20 enter no. to search : 20

3362


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

3266


Create a program to read two random data set in two files named data1.txt and data2.txt manifold contains integer numbers, whereas data2.txt file contains the float type numbers. Simpanlahmasing each into 2 pieces of data that is an array of type integer array and an array of type float, then calculate the average numbers in the second array.

2142