how we can find the maximum number of a vector? which order?
thank you
find maximum numaber of vector
Moderators: silvia, selimgunay, Moderators
-
- Posts: 140
- Joined: Sun Oct 03, 2010 11:36 pm
- Location: Hong Kong
Re: find maximum numaber of vector
tcl language or C++?
how about a loop
for (int i = 0; i < size(); i++)
if (x[i] < xMin)
xMin = x[i];
how about a loop
for (int i = 0; i < size(); i++)
if (x[i] < xMin)
xMin = x[i];
Research Assistant Professor, The Hong Kong Polytechnic University
guanlin@polyu.edu.hk
guanlin@polyu.edu.hk
-
- Posts: 4
- Joined: Wed Mar 06, 2013 12:48 pm
Re: find maximum numaber of vector
tank you ,
at tcl language please?
farzin rezazadeh
PhD candidate
Civil and Structural Engineering
Tehran University, IRAN
at tcl language please?
farzin rezazadeh
PhD candidate
Civil and Structural Engineering
Tehran University, IRAN
Re: find maximum numaber of vector
proc maxValue list {
set index 0
set maxindex $index
set maxval [lindex $list 0]
foreach val $list {
if {$val > $maxval} {
set maxindex $index
set maxval $val
}
incr index
}
return $maxval
}
set index 0
set maxindex $index
set maxval [lindex $list 0]
foreach val $list {
if {$val > $maxval} {
set maxindex $index
set maxval $val
}
incr index
}
return $maxval
}
-
- Posts: 4
- Joined: Wed Mar 06, 2013 12:48 pm
Re: find maximum numaber of vector
tank you dear