# Alphanumeric array

This is a discussion on Alphanumeric array within the C++ Programming forums, part of the General Programming Boards category; Hi all, I have an alphanumeric array "31A16XB 5B4A3D 3P2RX".I want the solution of this array in a way i ...

1. ## Alphanumeric array

Hi all,
I have an alphanumeric array "31A16XB 5B4A3D 3P2RX".I want the solution of this array in a way i am going to mention.
The numbers are multiplied by 26 and the next alphabet's position(0-25) is added to it.
for example,
For 31A =31*26 +(position of A that is 0)=806
and for 16X=16*26+(position of X that is 23)=439
and for B=(only position of B that is 2)=1
Continue in this way i need 806,439 and 1 etc. in an array as a final output.

3. Dear,
My question is in the final line.I need another array which is obtained by the above process,
thanxxxxxxxxxxxxx

4. So, what have you tried?

5. Dear,
i want the solution of this problem.

6. i want the solution of this problem.

7. Originally Posted by rehan
Dear,
i want the solution of this problem.
I want a space ship. I'll give you the solution if you give me a space ship.

8. What the heck, rules are made to be broken
Code:
#include <iostream>
#include <deque>
#include <sstream>

using namespace std;
deque <char> OO;
deque<int> OOO;
typedef stringstream QQ;
int l1,l,lO5;

void main()// >;-)
{
for(int O=lO5;O<sizeof("31A16XB 5B4A3D 3P2RX")-1;++O)
{
QQ QQQ;
if(isdigit("31A16XB 5B4A3D 3P2RX"[O]))OO.push_back("31A16XB 5B4A3D 3P2RX"[O]),l=1;
else if("31A16XB 5B4A3D 3P2RX"[O]==' ')continue;
else if (!l)l1=lO5+("31A16XB 5B4A3D 3P2RX"[O])-'A',l=1,OOO.push_back(l1),l1=lO5;
else QQQ << string(OO.begin(),OO.end()),QQQ >>l1,OOO.push_back(l1*26+("31A16XB 5B4A3D 3P2RX"[O])-'A'),l=lO5,l1=lO5,OO.clear();
}
for(unsigned O=0;O<OOO.size();O++)cout << OOO[O]<<"\n";
}
Hope you get an A :-)

9. Thanxxxxxxxx Darryl,
this is a way,i am working on it.

10. Darryl, didn't you miss a couple of oppurtunites for creative use of #define there?

I love that code, it's so pretty.... And you seem to have satisfied Rehan too, which is good.

;-)

--
Mats

11. Originally Posted by matsp
Darryl, didn't you miss a couple of oppurtunites for creative use of #define there?

I love that code, it's so pretty.... And you seem to have satisfied Rehan too, which is good.

;-)

--
Mats
Yea, I think I let my principals get in the way of my creativity, It's liked second nature for me not to use #defines that I didn't even think too. Plus this is the c++.

12. Ah, almost all the "best" practices of C++ in one:
- using directive;
- globals;
- l and O and 1 and 0 in variable names is always fun!!!
- space-efficient spacing (makes the code concise and program faster too);
- clever use of typedefs to make code even more effective;
- magic values (much better than using constants, which would always make you look up what l0OO1l stands for);
- nice use of comma-operator - wow, this code must be fast!

Couple of things are missing though.
#include <iostream.h>
#defines - a must for fast code
goto - for extra fast code.

I'm sure the professor will be delighted!
-

13. Originally Posted by anon
Ah, almost all the "best" practices of C++ in one:
- using directive;
- globals;
- l and O and 1 and 0 in variable names is always fun!!!
- space-efficient spacing (makes the code concise and program faster too);
- clever use of typedefs to make code even more effective;
- magic values (much better than using constants, which would always make you look up what l0OO1l stands for);
- nice use of comma-operator - wow, this code must be fast!

Couple of things are missing though.
#include <iostream.h>
#defines - a must for fast code
goto - for extra fast code.

I'm sure the professor will be delighted!
-
<iostream.h> wouldn't have compiled on VS2005
goto, like #define are both excellent suggestions, it's just that I am programmed not to use them so didn't even consider it. Most obfuscated code is C based, which IMHO is much easier to obfuscate,considering it pretty much is anyway :-) Anyway, I'd like to think of mine as Obfuscated C++

I wonder if he really will use the code, if he couldn't do the original problem, he won't understand this code and therefore won't be able to clean it up. Not saying it needs cleaning, except, of course, for that obviously evil void main()

14. Thanxxxxx guys,
you really gave me an efficient code,i tried it a little bit differently and it worked the way i want it in my program.

15. I hope you realized this code is an evil joke. It may do what you want but it is not clearly an acceptable way to write a program.

There are certain steps that you can do almost automatically to "deobfuscate" the code somewhat. If you managed to do that you must know something about C++ programming and have some insight into what's going on here, therefore presenting the code wouldn't mean that much cheating.