|
Try this:
#define MISTERY(x,v) (((x)<(v))? 1 : 0 )
#define SECRET(x,a,b) ( ! ( MISTERY(x,a) || MISTERY(-x,-b) ) )
Then, in your function:
return SECRET(x,0.5,1.0)
Not only I avoided using the dreaded if statement, but I also succeeded in making the code more dificult to predict. A genuine 2 in 1.
Anyway, the only reason I see to avoid using the if statement is to look good when answering a teacher's question! :-P
Rogério Rilhas
PS: I sincerely hope there is no hidden bug in this code!!
|
|
|
|
|
how to read outlook express file inbox.dbx to simple english .
how we can recover deleted mail from inbox.dbx
naveen padiyar
|
|
|
|
|
Hi,
I want to know how to create (control the generation of) my own public & private key pairs, is it correct to use the following codes? And what are valid parameters P, Q, Modulus, any sample codes?
----------------------------------------------------------------------
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(1024);
System.Security.Cryptography.RSAParameters parameters = new System.Security.Cryptography.RSAParameters();
parameters.P=???;
parameters.Modulus=???;
.............
...............
rsa.ImportParameters(parameters)
----------------------------------------------------------------------
Thanks & best regards,
Ed.
|
|
|
|
|
Hello
This is my first programming class and I need help. I am being asked to design an algorithm for a converter that converts
units in Metric to English and vice versa. The choice of code is pseudocode.
Please if someone would at least write an example for me of this code I could study it and use it as a teaching aide to help me understand how this works.
Thank You
|
|
|
|
|
xcom2001 wrote: Please if someone would at least write an example for me of this code I could study it and use it as a teaching aide to help me understand how this works.
pseudocode is an english like structured language, which basically means it is what you want it to be. It is Pseudo because it is not a real language and is not meant to represent any real language. If you are not an english speaker, pseudocode is what ever you generally speak.
a quicksort algorithm which is a divide and conquor technique that is very famous, would look like this:
function quicksort(a, left, right)
while right > left
select a pivot value a[pivotIndex]
pivotNewIndex := partition(a, left, right, pivotIndex)
leftSize := (pivotNewIndex-1) - left + 1
rightSize := right - (pivotNewIndex + 1) + 1
if leftSize < rightSize
quicksort(a, left, pivotNewIndex-1)
left := pivotNewIndex+1
else
quicksort(a, pivotNewIndex+1, right)
right := pivotNewIndex-1
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
xcom2001 wrote: This is my first programming class and I need help. I am being asked to design an algorithm for a converter that converts
units in Metric to English and vice versa. The choice of code is pseudocode.
Please if someone would at least write an example for me of this code I could study it and use it as a teaching aide to help me understand how this works.
Here is an example of one of the routines you will need:
To convert some centigrade degrees to some fahrenheit degrees:
Put the centigrade degrees into the fahrenheit degrees.
Multiply the fahrenheit degrees by 9.
Divide the fahrenheit degrees by 5.
Add 32 to the fahrenheit degrees. Incidently, though most people would consider this "pseudocode", it is actually Plain English code and can be compiled and run using the Osmosian Order's Plain English development system (which was written entirely in Plain English).
|
|
|
|
|
The Grand Negus wrote: is actually Plain English code and can be compiled and run using the Osmosian Order's Plain English development system
|
|
|
|
|
That's great, but can you please stop using every chance you see to include the words "can be compiled and run using the Osmosian Order's Plain English development system (which was written entirely in Plain English)" or any variant thereof.
I don't want a discussion on how you didn't actually include an email address or URL, or how you are helping this person by providing a solution that is also in actual 'useable' code. I just want you, as I have asked many times before, to cease using these forums for self promotion.
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
Chris Maunder wrote: I just want you, as I have asked many times before, to cease using these forums for self promotion.
Self promotion, as we've discussed before, is the wrong term. As I've said many times before, what we're promoting is ideas - in this case, the ideas that (1) people naturally think, not in artificial languages, but in natural languages, of which pseudocode is a degenerate case; and (2) since pseudocode-like languages can be compiled and run and used to develop even low-level programs like compilers and high-level programs like page editors, we should all reconsider the role of artifical/natural languages in computer programming. The original poster is just starting out and we wouldn't want this person to be denied exposure to all aspects of "state of the art", now would we?
Our Plain English development system is nothing but a "proof of concept" that we offer, here and elsewhere, to eliminate unnecessary responses claiming our ideas are "nice, but impractical". That's all. The product is not important except as a working manifestation of the ideas behind it.
|
|
|
|
|
I will repeat: Enough is enough.
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
Chris Maunder wrote: Enough is enough.
But enough of what?
Exhibit A - In a thread about Latex I suggest that a wysiwyg approach might be a better alternative, with a reference to a commercial product as proof of concept [^].
Exhibit B - In a thread about pseudocode I suggest that thinking of pseudocode as real code might be a better alternative, with a reference to a commercial product as proof of concept [^].
What's the difference? And please don't say that I have a vested interest in one and not the other because (a) you don't know that, and (b) it wouldn't affect the points being made anyway.
|
|
|
|
|
The Grand Negus wrote: Chris Maunder wrote:
Enough is enough.
But enough of what?
enough of you of course... !
|
|
|
|
|
toxcct wrote: enough of you of course... !
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|
|
Chris Maunder wrote: I will repeat: Enough is enough.
If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa
|
|
|
|
|
The Grand Negus wrote: Self promotion, as we've discussed before, is the wrong term.
Actually, I think it's pretty much spot on. Don't get me wrong; I don't really care one way or the other if you use this forum for self promotion. Denying it is futile however. In general you only reply to questions which give you some "plausibile deniability".
Steve
|
|
|
|
|
Stephen Hewitt wrote: In general you only reply to questions which give you some "plausibile deniability".
Actually, I reply when the opportunity presents itself to promote - not myself - but one or more of several principles that lead to different ways of thinking about programming, and that, when applied, produce significantly different programs. Our Plain English development system is one example.
|
|
|
|
|
The Grand Negus wrote: Our Plain English development system is one example.
If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa
|
|
|
|
|
The Grand Negus wrote: reply when the opportunity presents itself to promote - not myself - but one or more of several principles that lead to different ways of thinking about programming, and that, when applied, produce significantly different programs.
In other words, you reply to promote your ideas. Which, regardless of their intrinsic value, often havea rather tenuous relationship to the topics being discussed prior to your reply. Example: i think this thread at one time had something to do with UOM conversions...
(BTW - since most of us know you only by your ideas, drawing a distinction between them and yourself is somewhat pointless)
|
|
|
|
|
Shog9 wrote: In other words, you reply to promote your ideas.
Doesn't everyone? Or are you responding for someone else?
Shog9 wrote: Example: i think this thread at one time had something to do with UOM conversions...
Check back, Shog. The topic was pseudocode. And the link between pseudocode and Plain English code is both short and direct.
Besides, you know how I hate to see beginners get off on the wrong foot. How could I resist?
|
|
|
|
|
Shog9 wrote: (BTW - since most of us know you only by your ideas, drawing a distinction between them and yourself is somewhat pointless)
On the contrary, the ideas (at least the good ones) existed long before I did, and will certainly live on long after I'm dead. I'm just a "link in the chain" - a present voice enunciating eternal truths in ways suited to my contemporaries. Others have gone before me, and still others will pick up the torch when I'm gone.
By the way, what do you see as your role in the great scheme of things?
|
|
|
|
|
The Grand Negus wrote: On the contrary, the ideas (at least the good ones) existed long before I did, and will certainly live on long after I'm dead.
Quite likely. But the ideas that you espouse, good and bad, identify you. A quick scan through this thread reveals three examples of pseudocode, each unique (within the context of this thread at least). You are known in this thread by your pseudocode. You are also known in this thread by your bringing up the notion of a compiler that accepts a pseudocode-like syntax as input (although, it wouldn't exactly be pseudocode in that case). This latter idea is the one you've become known for, to the extent that separating you from the idea isn't an activity likely to be seen as productive by... anyone here.
The Grand Negus wrote: By the way, what do you see as your role in the great scheme of things?
Grease on the cogs, catalyst in the concoction. Maybe.
|
|
|
|
|
Shog9 wrote: This latter idea is the one you've become known for, to the extent that separating you from the idea isn't an activity likely to be seen as productive by... anyone here.
Which is a shame. And something, frankly, that I don't understand. Our message, stated in many ways and in many places in these forums, is this: Programming isn't fun anymore. It's not fun to learn, it's not fun to teach, and it's certainly not fun as an occupation. One can no longer master the machine, the operating system, or the development tools - they're just too damn and unnecessarily complicated. But since no one can create who is not master of his tools, the image of God in us - the little creator made after the pattern of the Big Creator - is squelched. The whole thing, therefore, must be simplified or we die (or at least the only part of us that matters, the creative part, dies).
And what steps do we recommend? Well... y'know.
Shog9 wrote: Grease on the cogs, catalyst in the concoction. Maybe.
Fair enough. Start there. But take care not to weary in well-doing, and don't let cowardice or laziness or both keep you from the next step. You're clearly much too gifted to spend your life as an oil can.
|
|
|
|
|
The Grand Negus wrote: Our Plain English development system
Haven't you taken the hint that most people here are not interested in Plain English? This site is a Microsoft technologies based site.
If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa
|
|
|
|
|
PaulC1972 wrote: Haven't you taken the hint that most people here are not interested in Plain English?
Define "most". Supply verifiable numbers to support your definition.
|
|
|
|
|
The Grand Negus wrote:
Supply verifiable numbers to support your definition.
That's not necessary, just look at the "nasty" replies you get
If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa
|
|
|
|
|