No offense man, but that is technically doing it most of the work for him..how can he learn then?

No offense man, but that is technically doing it most of the work for him..how can he learn then?

Hon i am learning the express way now.basically i posted the codes before.look at the first page.he just compile it for me.i learned all that in a week.you think its easy on me?
sorry if i am rude here

LMAO..no i REALLY mean no offense 8-) but its because i know someone at friendster called wai hoe..is that you as well?
Cos if you are then its kewl =) cos he's a nice guy :)

Sorry i meant Wai Hoe a.k.a. Kellaw 8-) his blogs and all are real nice..
Back to topic..yes char is better instead of int as it saves time typing
(x/(power(10,i))%10) this and all.

Huh? Kellaw is my family name. I live in Durham and i do not have friendster or what you call that. Blogs? Nothing to do with this topic. So its off topic. If you want to know more about my name and roots where i decended from the 14th century bishop. Here is the add http://www.livelyroots.com/gerald/103.htm and also http://www.callawayfamily.org/kellchat2001.htm.
back to topic
i reversed the stack using a temp stack and pop into the program..the reason is when i for example key in 10010 and using the loop
for (i=0;i<15;i++)
stack.push(x/(power(10,i))%10)

it will end in 0 being the bottom of stack and 1 top of stack
then pop and push into the temp stach we will get 1 at the bottom and 0 at the top
so when we pop we pop the 0 which if its value is 1 it will represent 1 in decimal.

You're complicationg things up m8..Why would you want to reverse the stack?
Besides, iamthwee already gave you the solution.

OffTopic:
Hmm..Okay.I'm gonna give you the benefit of the doubt. Truth is, you've got lots of reason to be suspicious about. See:
1. SOMEONE in Disted College Takes computer science course AND *it just so happens* have the same question you asked..AND *it just so happens* you gave the same stack; the EXACT AND *it just so happens* that your surname is = to his nick. Not to mention that you've got a slightly poor way of sentencing and im pretty sure that the Kellaws would have great grammar seeing as they're from Durham.
*I am not insulting your heritage nor your grammar*
So yeah. I dunno, just seems to strike to me that there's just WAY too many coincidences.

Disted College? Same name? He is in an IT course? Same question? You know why am i asking this question in the first place? Look up previous posts and that explains all. Does this means you are here for a solution also? Well I think you have the solution you need for your work now but i have more to ask. The stack was copied from a book. I think it's universal. Well I wonder how he got my family name as his nick. Did I mention language comes from practice?
Reversing the stack to pop from the bottom is the point there. Because my loop starts at 0 and ends at 15.

LOL no offense..but i've done it before you posted this 8-)
No you didn't mention language comes from practice..besides, you should've grown up speaking English no?
I highly doubt it's copied from a book since the Disted lecturer is kinda diligent and all~
And i know you're asking about reverse stack, I thought it was relevant to the assignment question 8-)
BTW, why are you sounding so worked up for? I was stating my doubts wasn't taking a gun and pointing it at your head and blaming you.

Nope. English is not my native language. I speak in French more. That's the problem I face when I got into high school. Everyone speaks english and I am the only one whoe doesn't. You mean the lecturers at your place copy from books? I think you can find the code in many books as it is widely used as what my friend told me. I am in a bad mood lately. I have my engineering assigments to finish just for the open day next week and i haven't slept much the last two days. it's already 8.30 here so I got to be going or I will be late for class yet again. Bye. Do leave me with a better solution if you have it.

Owh. you're studying at Durham? Cool
You misunderstood me. I meant that the lecturer would not use questions from the book since he/she is quite hardworking. Besides, there is a way to convert from binary > others in an easier way, but your lecturer wants it in stacks.

Owh. you're studying at Durham? Cool
You misunderstood me. I meant that the lecturer would not use questions from the book since he/she is quite hardworking. Besides, there is a way to convert from binary > others in an easier way, but your lecturer wants it in stacks.

Reached uni. I am pretty sure your lecturer use a book for that question. Because my lecturer show me the book before and he asked me to do it in the stack way. The reason is because when you scan a barcode it will be single boolean digits. I am aware that there is also the template way of solving posted in my first post.Got to go now. Class starts at 9

Member Avatar for iamthwee

>No offense man, but that is technically doing it most of the work for him..how can he learn then?

That's nice, but if you read before most of that code was written by him, I just showed him how to use it with chars.

>Do leave me with a better solution if you have it.

Duh, I've showed you the best solution. Again I ask the question, why are you trying to reverse the stack kiddo?

And the now to the main question. Have you got your stack prototype working with you current program?

>No offense man, but that is technically doing it most of the work for him..how can he learn then?

That's nice, but if you read before most of that code was written by him, I just showed him how to use it with chars.

>Do leave me with a better solution if you have it.

Duh, I've showed you the best solution. Again I ask the question, why are you trying to reverse the stack kiddo?

And the now to the main question. Have you got your stack prototype working with you current program?

i havent have it runned yet.i explained why in the last post.lets say
cin>>x; x=1010

for (i=0;i<15;i++)
stack.push(x/(power(10,i))%10)
which means the value stored in the stack is 1,0,1,0
where when you pop you pop 1 1st then followed by 0 then 1 and 0.
i put the temporary stack to accept the popped stack to make it 0101 so i can pop 0 then 1 then 0 and 1
the 0 is calculated as multiply 0 to 2 power of 0 and then the 1 multiply 2 power of 1. then it sums up the total in each loop
so in the end i get total as 10
get what i mean?or i may be wrong

Member Avatar for iamthwee

>for (i=0;i<15;i++)
stack.push(x/(power(10,i))%10)

I honestly have no idea why you would want to do it that way instead of using chars? Obviously, I've never worked with peripheral devices like bar scanners so I don't know how the information is coming in.

It seems odd though, that you insist the 15 digit binary number be represented as a what... long int???, instead of a char array? Why not ask your teacher what's best.

And you still seem to insist that it will be easier if you reverse the stack? Erm why? Do you even know how to convert binary numbers to decimal, do you even know the basic design of a stack? Have you even read and digested my code, which was originally suggested by YOU?

And shouldn't you now be trying to get your stack prototype to work instead of worrying about this other nonsense, which I have alreadly told you, you don't need to worry about.

Kiddo, you're doing an engineering degree. Sure programming probably ain't your thang, but for goodness sake grow some balls and start using your brain. :rolleyes:

hey all
first i am web developer not software one, but i had knowledge in algorothem.
kellaw i won't write code only i will tell u the algorithgm.
i suppose the binary stack is stored in array (A) from left to right.
first create 2 arrays (B) and (C) with same number of cells in A. B will contain A in opposite " u can do it its easy".
C will contain even numbers.
second, do a loop to search B and whatever find a cell containing 1, just count using C.
sum = 0
for i=0, i<B.lenght - 1
if B == 1 then
sum += C
i++

thats it, implement and tell me what happened.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.