largest no

  • Thread starter bele_harshad2006
  • Start date
R

Richard Heathfield

Keith Thompson said:
If the exchanges are truly random, that's not guaranteed to terminate,
so it doesn't qualify as an algorithm.

while not sorted
pick two elements at random
if they are disordered
exchange them
otherwise
find the first two elements that are disordered, and exchange them
end if
endwhile

Not quite as satisfying, but at least it will terminate at some point.
 
C

Chris Dollin

Joachim said:
Me too I must admit. Isn't that what smileys have been invented for?

Smileys are a (n ubsubtle) replacement for tone-of-voice and so
should be omitted when wouldn't use the tone-of-voice signal,
such as in written text.

--
"Our future looks secure, but it's all out of our hands." /Man and Machine/
- Magenta

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England
 
T

Tak-Shing Chan

Smileys are a (n ubsubtle) replacement for tone-of-voice and so
should be omitted when wouldn't use the tone-of-voice signal,
such as in written text.

Subtle humours are linguistic puzzles in disguise and so
should be omitted when these off-topic elements are lowering the
signal-to-noise for the newsgroup, such as comp.lang.c.

Tak-Shing
 
C

Chris Dollin

Tak-Shing Chan said:
Subtle humours are linguistic puzzles in disguise

So is text.
and so
should be omitted when these off-topic elements are lowering the
signal-to-noise for the newsgroup, such as comp.lang.c.

Wouldn't leave much.

Use all the smileys you like -- take my spare ones if you will.
 
R

Richard Heathfield

Chris Dollin said:

Use all the smileys you like -- take my spare ones if you will.

He's already pinched all mine. I think he's going for a global monopoly.
 
C

Chris Dollin

Do you recommending declaring those in header files?

I haven't a clue about whether that's too risky. You might have to
scrabble around -- the history of the world makes it likely -- to
acquire the right careers. Once in a blue moon, some campaign
against smileys might succeed ...

--
"We did not have time to find out everything /A Clash of Cymbals/
we wanted to know." - James Blish

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England
 
R

Richard Heathfield

Chris Dollin said:
I haven't a clue about whether that's too risky. You might have to
scrabble around -- the history of the world makes it likely -- to
acquire the right careers. Once in a blue moon, some campaign
against smileys might succeed ...

And that will be the end of civilization as we know it, or something
equally trivial.
 
K

Kevin Handy

how can i pick up largest no from 5 rows by 5 column matrix????
Depends on how you measure your 'no's.

If it is by font size, then you will have to
rely on your OS/GUI to determine their sizes,
which is off-topic for this group.

If it is by number of characters, then it
should always be 2. If you allow usage
of foreign versions of 'no', then you will
need to use strlen(), and a dictionary lookup
to select just those words defined to be
'no'.

If you are using some other form of
measurement, please give us a better set of
specifications.

Since this sounds like a homework assignment,
please give us your teachers address to send
the responses to.
 
T

Tor Rustad

Keith said:
No, it's not. A truly random generator can generate any possible
sequence, including a sequence that causes the code to repeatedly swap
the first two elements forever. The worst-case behavior is that it
never terminates.
Correct.

It isn't certain to terminate, but it terminates in some finite time
with probability 1.

That is a really deep one, but I also beleave it's correct, typically a
topic my brother try to explain when we both are drunk. I never get it.

In any case, this stopped being about C some time ago.

Sure, but if the student (OP) follow this far, he would learn something!
 
R

Richard Bos

Tor Rustad said:
That is a really deep one, but I also beleave it's correct, typically a
topic my brother try to explain when we both are drunk. I never get it.

It is guaranteed to terminate in _some_ finite time, but whatever finite
time you choose to wait for it to terminate in, there is a non-zero
possibility that it may terminate in longer than that. Very sloppily
put, it will eventually terminate, but that termination point may be at
T+1, for _all_ finite T. (Even more sloppily put, it must terminate, but
it may do so at T=infinity. Which, in mathematics, is not the same thing
as not terminating at all, at any time.)

Richard
 
A

Army1987

how can i pick up largest no from 5 rows by 5 column matrix????

Use a variable (which I'll call max) to hold the element in the top
left corner, then loop through rows and columns, and, wherever you
find a number greater than max, assign it to max.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top