Maximum

Category: C/C++ -> Beginner Author: wuxuefeng0310 Date: 2004-04-06 20:08:12
 
wuxuefeng0310
2004-04-06 20:08:12
I would like to ask, how to find the maximum number N! Thank
xsj_jay
2004-04-06 20:13:47
you first assume that the first one is the largest, and then one by one and another, and if there is more than the value of the first big put out, then down to do, until N numbers are Compare over. then output on the line ah!!!
xiagaofeng512512
2004-04-06 20:23:46
I mean the code!
zhangduyi520
2004-04-06 20:40:20
int a [100], max = a [0];
for (int i = 1; i <100; i + +) {
if (max <a [i]) {
max = a [ i];
}
}
langyuqian
2004-04-06 20:49:42
for ()
{
for ();
}
lnalry
2004-04-06 20:59:14
are N number of do /
iceregion124
2004-04-06 21:06:52
100 rather than seeking the N's. How requirements.
panzhuo616
2004-04-06 21:44:10
direct request code, turn novice Paradise
yaom123130
2004-04-06 22:11:32
Louzhu, you are not too lazy, and what someone else gave you written, can also pay for you took?
caonimi110
2004-04-06 22:34:38
Then you record your first with the count i write into several said, and then do qfeng_zhao (every day) that do not step on the line ah!!! code to write their own This is very basic simple!!!
gzbmw
2004-04-06 22:55:48
# include <iostream>
using namespace std;
int main ()
{
int * a, n, i, max;
cout << "please input n" << endl;
; cin >> n;
a = new int [n];
for (i = 0; ; i <n; i + +)
cin >> a [i];
for (i = 0; i <n; i + +)
if (max <a [i])
; max = a [i];
cout << "max =" << max << endl;
return 0;
}
liuyong19760826
2004-04-06 23:28:59
# include <iostream.h>

void ; main ()
{
int i, n = 0, num, max_ = 0;
cout << "Please input num" << ; endl;
cin >> num; ; / / N setting

cout << "input your data "<< endl;
while (n <num)
{
cin >> i;
n + +;
max_ = (i> max_? i: max_);

}

cout << "max =" << max_ < <endl;
}
xwh895308942
2004-04-06 23:47:40
a pit
I jumped
chj7513
2004-04-07 00:24:15
Oh such a problem to this question does not know the landlord is true or false lazy lazy

yourself smiling now
ll5859
2004-04-07 00:55:55
# include <stdio.h>
void main ( )
{
double max;
int i, b;
printf ("Please enter your desired number of digits in a set of numbers, with a carriage return at the end: \ n ");
scanf ("% d ", & b);
double a [10000];
printf (" Please enter you need a set of numbers, As each number with a carriage return marks the end of each number: \ n ");
for (i = 0; i <b; i + +)
scanf ("% lf ", & a [i]);
max = a [0];
for (i = 1; i <b; i + +)
{
if (max <a [i]) max = a [i];
else max = max;
}
printf ("The maximum value is:% lf", max);
}