C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 15th, 2012, 04:07 AM
JamPoc JamPoc is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 JamPoc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 28 sec
Reputation Power: 0
Help needed with for loop

Hi, I have some Micro code to change ASAP that is wrote in C++ I am not that good on C++ (understatement of the year)
So I was hoping someone help.

Here is the current code

case bt_measure:
{
if(ticks<5)
return;

test_report = ts_testing;

if(param2<1)
param2=1;

for(int i=0; i<5; i++)
mV[i] = 0;

if(!BondRead(3,adc_bond_i)) return;
if((bond_range==0) && (mV[3]<(param1 * 400)))
{
BOND_FULL(true);
bond_range = 1;
return;
}

mV[3] *= param2;
for(int repeat = 0; repeat < param2; repeat++)
{

if(!BondRead(0,adc_bond_diff)) return; // Uncommented by JP 14/11/12
if(!BondRead(1,adc_bond_va)) return; // Uncommented by JP 14/11/12
if(!BondRead(2,adc_bond_vb)) return; // Uncommented by JP 14/11/12
if(!BondRead(4,adc_bond_auto)) return;

T2CLRI = 0;
}

test_state = bt_start2;

for(int i=0; i<5; i++)
mV[i] /= param2;

break;
}

Currently depending on the user input this code will execute param2 number of times then take an average before displaying to the user.
Now I need it more clever,
Say I get 5 values
0.4
2.4
2.1
2.3
I need it to group every number thats within 5% of each other and ignore all others then return the average of the 5% group

Can anyone please help

Reply With Quote
  #2  
Old November 15th, 2012, 12:12 PM
ediz ediz is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2012
Posts: 102 ediz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 35 m 33 sec
Reputation Power: 3
Posted wrong.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Help needed with for loop


Developer Shed Advertisers and Affiliates


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap