Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[急]請問VC++中..min與max要如何用呢

0 views
Skip to first unread message

泌涼

unread,
Mar 7, 2003, 8:40:55 AM3/7/03
to

請問..
假設我現在有兩個數..
分別為
呃...
3與19好了...

我想要去取最大值出來... max(3,19) -->19
我想要去取最小值出來... min(3,19) -->3
請問我要怎麼寫呢..
有什麼函式可以讓我呼叫呢..
有什麼header file要include呢...

可否麻煩教我一下..謝謝..
--
[1;32m※ Origin: [33m交大資工鳳凰城資訊站 [37m<bbs.csie.nctu.edu.tw> [m
[1;31m◆ From: [36mc191.ime.ncku.edu.tw [m

哇靠我要吃盡天下美食!

unread,
Mar 7, 2003, 8:45:04 AM3/7/03
to
※ 引述《ccov...@bbs.csie.nctu.edu.tw (泌涼)》之銘言:

> 請問..
> 假設我現在有兩個數..
> 分別為
> 呃...
> 3與19好了...
> 我想要去取最大值出來... max(3,19) -->19
> 我想要去取最小值出來... min(3,19) -->3
> 請問我要怎麼寫呢..
> 有什麼函式可以讓我呼叫呢..
> 有什麼header file要include呢...
> 可否麻煩教我一下..謝謝..
include algorithm
using function : max, min ..
--
只看你所擁有的,不看你所沒有的。
--
[1;32m※ Origin: [33m元智大學 風之塔 [37m<bbs.yzu.edu.tw> [m
[1;32m※ From : [36m61-223-249-110.HINET-IP.hinet.net [m

小州

unread,
Mar 9, 2003, 3:10:30 PM3/9/03
to
※ 引述《starst...@kkcity.com.tw ( )》之銘言:
> //那如果是
> int a[20]=(........)
> //要怎樣排出裡面數字的順序??有函式嗎

若是你有學過資料結構的話,那應該可以簡單使用泡泡排序法這類很
簡單的方式來解決,要不然你就是需要熟悉 stl 內相關演算法。

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
int num[]={24,51,11,3,67,44,312,64,9,43,22};
int num2=0;

cout << "before...." << endl;
for(int i=0;i<sizeof(num)/sizeof(int);i++)
cout << num[i] << endl;

sort(&num[0],&num[12]);

cout << "after...." << endl;
for(int i=0;i<sizeof(num)/sizeof(int);i++)
cout << num[i] << endl;
}


--
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

現代人普遍的現象: 「小學而大遺」、「捨本而逐末」
「以偏而概全」、「因噎而廢食」
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--
[1;32m※ Origin: [33mSayYA 資訊站 [37m<bbs.sayya.org> [m
[1;31m◆ From: [36mkendlee.sayya.org [m

0 new messages