Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 03-31-2004, 12:29 AM   #1
Mondsreitersmann
 
Nuclear Krusader's Avatar
 
Join Date: Jul 1999
Location: Skingrad
Posts: 8,781
Pissed Yet another weird program

This one compiles but hangs when the Percentil function is called.

Any suggestions?

Here is the program

TIA
__________________
Darum still, füg' ich mich, wie Gott es will. Nun, so will ich wacker streiten, und sollt' ich den Tod erleiden, stirbt ein braver Reitersmann.
Nuclear Krusader is offline   Reply With Quote
Old 03-31-2004, 01:05 AM   #2
Mondsreitersmann
 
Nuclear Krusader's Avatar
 
Join Date: Jul 1999
Location: Skingrad
Posts: 8,781
Forgot to add the .dat file.

Just change the extension from txt to dat, please.
Attached Files
File Type: txt indata2.txt (213 Bytes, 27 views)
Nuclear Krusader is offline   Reply With Quote
Old 04-01-2004, 08:31 AM   #3
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Line 141, in function Percentil:
Code:
while (i<index);
    {
    // ...
and "i" never changes in the while loop, add "i++;" to the end of the loop.

Hehe, it took me a while to notice that semicolon
aym is offline   Reply With Quote
Old 04-01-2004, 12:34 PM   #4
Mondsreitersmann
 
Nuclear Krusader's Avatar
 
Join Date: Jul 1999
Location: Skingrad
Posts: 8,781
I am such a noob!!!

Thanks, aym.
Nuclear Krusader is offline   Reply With Quote
Old 04-01-2004, 12:56 PM   #5
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
not really, it happens all the time, a couple of days ago I spent an hour or so trying to find out what was wrong with a small program I've written, after lots of looking here and there, it turned out that I used 1 / 3 which evaluates to 0, my bad, should have used 1.0 / 3.0

Last edited by aym; 04-01-2004 at 12:59 PM.
aym is offline   Reply With Quote
Old 04-05-2004, 10:07 PM   #6
Mondsreitersmann
 
Nuclear Krusader's Avatar
 
Join Date: Jul 1999
Location: Skingrad
Posts: 8,781
Aym, is there a way to make the histogram in a more efficient manner? I mean, another coding that can yield the same result without being that long?

TIA
Nuclear Krusader is offline   Reply With Quote
Old 04-06-2004, 02:57 AM   #7
Gremlin Overlord
 
Jaggannath's Avatar
 
Join Date: Apr 2003
Location: Australia
Posts: 2,382
Don't feel like a newbie NK, the average professional programmer makes 21 errors/1000 lines, and after checking over it once this only drops to 3 errors/1000 lines
Jaggannath is offline   Reply With Quote
Old 04-06-2004, 06:17 AM   #8
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Quote:
Originally posted by Nuclear Krusader
Aym, is there a way to make the histogram in a more efficient manner? I mean, another coding that can yield the same result without being that long?

TIA
Yeah, I forgot to comment on this, instead of using 10 variables for pc*, perc*, and p*, you can use arrays:

Code:
pci becomes pc[ i ]
perci becomes perc[ i ]
pi becomes p[ i ]
And use for loops with these arrays, the while loop in Percentil can be re-written like this:
Code:
while (val_i < index) {
    for (i = 0; i < 10; i++) {
        if (value[val_i] >= i * 10 && value[val_i] < (i + 1) * 10 ||
            value[val_i] == 100 && i == 9) {
            perc[i]++;
            break;
        }
    }
    val_i++;
}

for  (i = 0; i < 10; i++) {
    p[i] = (float)perc[i] / (float)index;
    pc[i] = (int)perc[i] * 100;
}
Same for the rest.
aym is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:51 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2