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 / 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 |
#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 |
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 |
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 |
Write a program using two-dimensional arrays that determines the highest and lowest of the 12 input values. Example: Enter 12 numbers: 13 15 20 13 35 40 16 18 20 18 20 14 highest: 40 lowest: 13
Coin Problem You are given 9 gold coins that look identical. One is counterfeit and weighs a bit greater than the others, but the difference is very small that only a balance scale can tell it from the real one. You have a balance scale that costs 25 USD per weighing. Give an algorithm that finds the counterfeit coin with as little weighting as possible. Of primary importance is that your algorithm is correct; of secondary importance is that your algorithm truly uses the minimum number of weightings possible. HINT: THE BEST ALGORITHM USES ONLY 2 WEIGHINGS!!!
1 Answers Motorola, Qatar University,
main(){int a=5,b 10,c=2, d;a=b c;d=++a=(--c)*2; printf("%d%d%d%d,a,b,c,d; return o;}
write a program that reverses the input number of n.Formulate an equation to come up with the answer.
Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)
Seat Reservation prog for the theatre. Write a function for seat allocation for the movie tickets. Total no of seats available are 200. 20 in each row. Each row is referred by the Character, "A" for the first row and 'J' for the last. And each seat in a row is represented by the no. 1-20. So seat in diffrent rows would be represented as A1,A2....;B1,B2.....;........J1,J2... Each cell in the table represent either 0 or 1. 0 rep would seat is available , 1 would represent seat is reserved. Booking should start from the last row (J) to the first row(A). At the max 20 seats can be booked at a time. if seats are available, then print all the seat nos like "B2" i.e (2 row, 3 col) otherwise Print "Seats are not available." and we must book consecutive seats only.
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,
Find the maximum product of three numbers in an array? Eg. 9,5,1,2,3 Max product= 9*5*3= 135 The array can hav negative numbers also..
Here's the programm code: int magic(int a, int b) { return b == 0 ? a : magic(b, a % b); } int main() { int a, b; scanf("%d%d", &a, &b); printf("%d\n", magic(a, b)); return 0; } on input stream we have integers 4, 45 What's the output integer? How many times will be initiated "magic" function?
PROBLEM #8 The cashier at the counter of a Super Store, Mr. Khazaanchi has the following bundles of rupee cash notes with him: Rs. 1, 2, 5, 10, 50, 100, 500, 1000 A customer comes at his counter with various items that he has shopped. Mr. Khazaanchi totals the item prices and tells the customer his total amount payable. The customer gives Mr. Khazanchi some amount of cash. Find the total number of rupee notes of each denomination (i.e. 1, 2, 5, 10, 50, 100, 500, 1000) Mr. Khazaanchi will have to give to the withdrawer ensuring that the total number of rupee notes are minimum.
Given 1 to n random number, find top 10 maximum numbers and explain the time complexity of the algorithm.
1. Write a program using one dimensional array that calculates the sum and average of the five input values from the keyboard and prints the calculated sum and average.