※ 引述《smarttb1 (呵呵)》之銘言:
: ※ 引述《mapleden (il'est fou)》之銘言:
: : 就是Chapter1的習題1.26
: : 怎麼樣都會跑錯
: : 知道的人能幫我debug一下嗎,謝啦^^
: : #include <iostream>
: : using std::cin;
: : using std::cout;
: : using std::endl;
: ^^^^^^^^^^^^^^^^其實這三行可以合寫成: using namespace std;
盡量不要吧
namespace的概念就是避免global var的污染
如果又這樣全部打開
結果還不是一樣
: : int main()
: : {
: : int a, b, c, large, small;
: : cout << "Please type in 3 different numbers\n";
: : cin >> a >> b >> c;
: : large=b;
: : small=a;
: : if (a>b){
: : large=a;
: : small=b;}
: : if (c<sl)
: : small=c;
: : if (c>le)
: : large=c;
: : cout << "Sum is " << a+b+c << endl;
: : cout << "Mean = " << (a+b+c)/3 << endl;
: : cout << "Product is " << a*b*c << endl;
: : cout << "Largest is " << large << endl;
: : cout << "Smallest is " << small << endl;
: : return 0;
: : }
: 這樣試看看行不行??
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.223.120.97