hello
please help me it's important
i want code c++ convert from array to another "
example:
user enter : acb
array1[0]=a
array2[0]=1
and
array1[1]=b
array2[1]=2
array1[2]=c
array2[2]=3
**out put for user : 132
**
thanksthankthanthatht
hello
please help me it's important
i want code c++ convert from array to another "
example:
user enter : acb
array1[0]=a
array2[0]=1
and
array1[1]=b
array2[1]=2
array1[2]=c
array2[2]=3
**out put for user : 132
**
thanksthankthanthatht
you know that each letter of the English alphabet has a decimal value, which can be found in any ascii chart, such as .this one. So, to solve your problem all you have to do is subtract the ascii value of 'a' from whatever the user input, then add 1 since you want the values from 1-26, not 0-25. For example, if you enter the letter 'b', the answer would be 'b' - 'a' + 1 = 98 - 97 + 1 = 2
Here is a program example
int main()
{
char n = '2';
int value = n - 'a' + 1;
printf("%d\n", value);
}
result: 2
You can now take the above one step further to apply it to the character array that you want. All you have to do is put that math algorithm in a loop .
Thank u
But this just example
I want two array then if user enter any string
search in first array then convert to second array
Example
a-> America
b ->-gprs
Are you understand me :"(
please help me
So in your example if I enter the string "America" the program should output "gprs"?
In that case you need an array of 2d strings.
char stringlist[99][2][100];
The above will give you 99 2d character arrays. Each string can have up to 100 characters.
stringlist[0][0] = "America"
stringlist[0][1] = "gprs"
stringlist[1][0] = "France"
stringlist[1][1] = "abc"
stringlist[2][0] = "Germany"
stringlist[2][1] = "def"
etc for each string
Now when someone enters "Germany", your program searches stringlist[0][0] to stringlist[99][0] for that text. When found, just output the value in stringlist[x][1] (assuming x is a loop counter 0-99)
general :)
if user entered "aman "
then process "search in array 1 and convert to array 2
output :
"isin"
"process (a convert to i ,, m convert to s , n convert to n)
general :)
if user entered "aman "
then process "search in array 1 and convert to array 2
output :
"isin"
"process (a convert to i ,, m convert to s , n convert to n)
So you are saying that the sequence of characters for array1 and array2 are already decided? In that case, your input string should be converted into a character array. Use a loop going through array1 to find the index of each character in the input, use that index to get the corresponding character from array2 and append that character to the output string.
yes i know what is in the array
but i want code can process that
please help me
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.