急!请C++高手进来帮小弟看一下作业后,感谢!
教授要求:classstatistician{public:...voidnext(doubler);doublemean()const;...};statisticia...
教授要求:
class statistician
{public:
...
void next(double r);
double mean( ) const;
...};
statistician s;
s.next(1.1);
s.next(2.8);
s.next(-0.9);
cout << s.mean( ) <<s.length()<<s.sum( )<<s.minimum( )<<s.maximum()<<endl;
我自己编了一点,求高手指教
//stats.h
#ifndef STATS_H
#define STATS_H
namespace main_2C
class statistician
{public:
void next(double r);
int length( ) const;
double sum( ) const;
double mean( ) const;
double minimum( ) const;
double maximum( ) const;
private:
}
//stats.cpp
#include <iostream>
#include <cstdlib>
#include "stats.h"
using namespace std;
using main_2C::statistician;
void statistician::next(double r)
{
}
int main()
{
statistician s1;
statistician s2;
statistician s3;
statistician s4;
s1.next(1.0);
s2.next(2.0);
s3.next(3.0);
s4.next(4.0);
system("PAUSE");
return EXIT_SUCCESS;
}
刚如门,现在不知道该怎么继续写下去...请高手看看!
上课例题很简单,自己编就完全不懂了
例题:
namespace main_2A
{
class point
{
public:
void initialize(double init_x, double init_y);
void shift(double dx, double dy);
double get_x() const;
double get_y() const;
private:
double x;
double y;
};
}
#endif
#include <iostream>
#include <cstdlib>
#include "point.h"
using namespace std;
using main_2A::point;
void point::initialize(double init_x, double init_y)
{
x = init_x;
y = init_y;
}
double point::get_x() const
{
return x;
}
double point::get_y() const
{
return y;
}
void point::shift(double dx, double dy)
{
x += dx;
y += dy;
}
int main( )
{
point p1;
point p2;
p1.initialize(-1.0,0.8);
cout << p1.get_x()<<", "<<p1.get_y()<<endl;
p2.initialize(p1.get_x(),p1.get_y());
cout << p2.get_x()<<", "<<p2.get_y()<<endl;
p2.shift(1.3,-1.4);
cout << p2.get_x()<<", "<<p2.get_y()<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
谢谢1楼大大...教授说不要自己写main,只要我编stats.cpp,他提供stats.h和statstest.cpp
补充字太少...2楼的是教授给的原始的stats.h和statstest.cpp 展开
class statistician
{public:
...
void next(double r);
double mean( ) const;
...};
statistician s;
s.next(1.1);
s.next(2.8);
s.next(-0.9);
cout << s.mean( ) <<s.length()<<s.sum( )<<s.minimum( )<<s.maximum()<<endl;
我自己编了一点,求高手指教
//stats.h
#ifndef STATS_H
#define STATS_H
namespace main_2C
class statistician
{public:
void next(double r);
int length( ) const;
double sum( ) const;
double mean( ) const;
double minimum( ) const;
double maximum( ) const;
private:
}
//stats.cpp
#include <iostream>
#include <cstdlib>
#include "stats.h"
using namespace std;
using main_2C::statistician;
void statistician::next(double r)
{
}
int main()
{
statistician s1;
statistician s2;
statistician s3;
statistician s4;
s1.next(1.0);
s2.next(2.0);
s3.next(3.0);
s4.next(4.0);
system("PAUSE");
return EXIT_SUCCESS;
}
刚如门,现在不知道该怎么继续写下去...请高手看看!
上课例题很简单,自己编就完全不懂了
例题:
namespace main_2A
{
class point
{
public:
void initialize(double init_x, double init_y);
void shift(double dx, double dy);
double get_x() const;
double get_y() const;
private:
double x;
double y;
};
}
#endif
#include <iostream>
#include <cstdlib>
#include "point.h"
using namespace std;
using main_2A::point;
void point::initialize(double init_x, double init_y)
{
x = init_x;
y = init_y;
}
double point::get_x() const
{
return x;
}
double point::get_y() const
{
return y;
}
void point::shift(double dx, double dy)
{
x += dx;
y += dy;
}
int main( )
{
point p1;
point p2;
p1.initialize(-1.0,0.8);
cout << p1.get_x()<<", "<<p1.get_y()<<endl;
p2.initialize(p1.get_x(),p1.get_y());
cout << p2.get_x()<<", "<<p2.get_y()<<endl;
p2.shift(1.3,-1.4);
cout << p2.get_x()<<", "<<p2.get_y()<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
谢谢1楼大大...教授说不要自己写main,只要我编stats.cpp,他提供stats.h和statstest.cpp
补充字太少...2楼的是教授给的原始的stats.h和statstest.cpp 展开
3个回答
展开全部
//stattest.cpp
#include <cctype>
#include <iomanip>
#include <iostream>
#include <cstdlib>
#include "stats.h"
using namespace std;
using main_2C::statistician;
void print_menu( );
char get_user_command( );
double get_number( );
void print_values(const statistician& s);
int main( )
{
statistician s1, s2, s3;
char choice;
double x;
cout << "Three statisticians s1, s2, and s3 are ready to test." << endl;
do
{
cout << endl;
print_menu( );
choice = toupper(get_user_command( ));
switch (choice)
{
case 'R': cout << "Which one should I reset (1, 2, 3) " << endl;
choice = get_user_command( );
switch (choice)
{
case '1': s1.reset( );
break;
case '2': s2.reset( );
break;
case '3': s3.reset( );
break;
}
cout << "Reset activated for s" << choice << "." << endl;
break;
case '1': s1.next(get_number( ));
break;
case '2': s2.next(get_number( ));
break;
case '3': s3.next(get_number( ));
break;
case 'T': cout << "The values are given in this table:" << endl;
cout << " LENGTH SUM"
<< " MINIMUM MEAN MAXIMUM" << endl;
cout << " s1";
print_values(s1);
cout << " s2";
print_values(s2);
cout << " s3";
print_values(s3);
break;
case 'E': if (s1 == s2)
cout << "s1 and s2 are equal." << endl;
else
cout << "s1 and s2 are not equal." << endl;
break;
case '+': s3 = s1 + s2;
cout << "s3 has been set to s1 + s2" << endl;
break;
case '*': cout << "Please type a value for x: ";
cin >> x;
s3 = x * s1;
cout << "s3 has been set to " << x << " * s1" << endl;
break;
case 'Q': cout << "Ridicule is the best test of truth." << endl;
break;
default: cout << choice << " is invalid. Sorry." << endl;
}
}
while ((choice != 'Q'));
return EXIT_SUCCESS;
}
void print_menu( )
{
cout << endl;
cout << "The following choices are available: " << endl;
cout << " R Activate one of the reset( ) functions" << endl;
cout << " 1 Add a new number to the 1st statistician s1" << endl;
cout << " 2 Add a new number to the 2nd statistician s2" << endl;
cout << " 3 Add a new number to the 3rd statistician s3" << endl;
cout << " T Print a table of values from the statisticians" << endl;
cout << " E Test whether s1 == s2" << endl;
cout << " + Set the third statistician s3 equal to s1 + s2" << endl;
cout << " * Set the third statistician s3 equal to x*s1" << endl;
cout << " Q Quit this test program" << endl;
}
char get_user_command( )
{
char command;
cout << "Enter choice: ";
cin >> command;
return command;
}
double get_number( )
{
double result;
cout << "Please enter the next real number for the sequence: ";
cin >> result;
cout << result << " has been read." << endl;
return result;
}
void print_values(const statistician& s)
{
cout << setw(10) << s.length( );
cout << setw(10) << s.sum( );
if (s.length( ) != 0)
{
cout << setw(10) << s.minimum( );
cout << setw(10) << s.mean( );
cout << setw(10) << s.maximum( );
}
else
cout << " none none none";
cout << endl;
}
//test.h
#ifndef STATS_H
#define STATS_H
#include <iostream>
namespace main_2C
{
class statistician
{
public:
statistician( );
void next(double r);
void reset( );
int length( ) const;
double sum( ) const;
double mean( ) const;
double minimum( ) const;
double maximum( ) const;
friend statistician operator +
(const statistician& s1, const statistician& s2);
friend statistician operator *
(double scale, const statistician& s);
private:
int count;
double total;sequence
double tinyest;
double largest;
};
bool operator ==(const statistician& s1, const statistician& s2);
}
#endif
没自己看要求,麻烦各位大大再帮我看一下...小弟在送10分
例子:
statistician s;
s.next(1.1);
s.next(2.8);
s.next(-0.9);
cout << s.mean( ) << endl;
教授要求:
# A default constructor, which merely does any initialization needed for the statistician to start its work
# The next and mean functions, described above
# A constant member function called length, which returns the count of how many numbers have been given to the statistician
# Two constant member functions called minimum and maximum, which return the smallest and largest numbers that have been given to the statistician. (By the way, these two functions and the mean function all have a precondition that requires length( ) > 0. You cannot use these three member functions unless the statistician has been given at least one number!)
# A constant member function called sum, which returns the sum of all the numbers that have been given to the statistician. This function does NOT have a precondition. It may be called even if the statistician has NO numbers (in which case it should return 0).
# An overloaded operator == which tests to see whether two statisticians are "equal". The prototype is:
int operator ==(const statistician& s, const statistician& t);
In order for two statisticians to be equal, they must have the same length (i.e., they have been given the same number of numbers). Also, if their length is greater than zero, they must also have the same mean, the same minimum, the same maximum, and the same sum. For example: Suppose that a statistician s has been given four numbers 1, 2, 3, 4. A second statistician t has been given four numbers 1, 1.5, 3.5, 4. Then the test (s==t) must return true since both s and t have equal values for all the member functions, as shown here:
1. s.length( ) and t.length( ) are both 4
2. s.mean( ) and t.mean( ) are both 2.5
3. s.sum( ) and t.sum( ) are both 10.0
4. s.minimum( ) and t.minimum are both 1
5. s.maximum( ) and t.maximum are both 4
# An overloaded + operator which has two statisticians as arguments, and returns a third statistician, as shown in this prototype:
statistician operator +(const statistician& s, const statistician& t);
# An overloaded * operator which allows you to "multiply" a double number times a statistician. Here is the prototype:
statistician operator *(double scale, const statistician& s);
This is not a member function. The result of a multiplication such as 2*s is a new statistician that looks as if it had been given all the numbers of s, multiplied by the constant 2. Examples: Suppose that s is a statistician that has been given 1, 2, 3, and u is another statistician. Then the assignment statement u=2*s will result in u behaving as if it had been given the numbers 2, 4, 6. As another example, the assignment statement u=-3*s will result in u behaving as if it had been given the numbers -3, -6, -9. Notice that neither + nor == are member functions. (See Section 2.5 in your textbook and the notes in lecture 3). The result of s+t is a new statistician that looks as if it had been given all the numbers of the sequence for s, followed by all the numbers of the sequence for t. For example: Suppose that we have three statisticians s, t, and u. The statistician s has been given the numbers 1, 2, 3; the statistician t has been given the numbers 4, 5. Then the assignment statement u=s+t will result in u behaving as if it had been given the five numbers 1, 2, 3, 4, 5.
#include <cctype>
#include <iomanip>
#include <iostream>
#include <cstdlib>
#include "stats.h"
using namespace std;
using main_2C::statistician;
void print_menu( );
char get_user_command( );
double get_number( );
void print_values(const statistician& s);
int main( )
{
statistician s1, s2, s3;
char choice;
double x;
cout << "Three statisticians s1, s2, and s3 are ready to test." << endl;
do
{
cout << endl;
print_menu( );
choice = toupper(get_user_command( ));
switch (choice)
{
case 'R': cout << "Which one should I reset (1, 2, 3) " << endl;
choice = get_user_command( );
switch (choice)
{
case '1': s1.reset( );
break;
case '2': s2.reset( );
break;
case '3': s3.reset( );
break;
}
cout << "Reset activated for s" << choice << "." << endl;
break;
case '1': s1.next(get_number( ));
break;
case '2': s2.next(get_number( ));
break;
case '3': s3.next(get_number( ));
break;
case 'T': cout << "The values are given in this table:" << endl;
cout << " LENGTH SUM"
<< " MINIMUM MEAN MAXIMUM" << endl;
cout << " s1";
print_values(s1);
cout << " s2";
print_values(s2);
cout << " s3";
print_values(s3);
break;
case 'E': if (s1 == s2)
cout << "s1 and s2 are equal." << endl;
else
cout << "s1 and s2 are not equal." << endl;
break;
case '+': s3 = s1 + s2;
cout << "s3 has been set to s1 + s2" << endl;
break;
case '*': cout << "Please type a value for x: ";
cin >> x;
s3 = x * s1;
cout << "s3 has been set to " << x << " * s1" << endl;
break;
case 'Q': cout << "Ridicule is the best test of truth." << endl;
break;
default: cout << choice << " is invalid. Sorry." << endl;
}
}
while ((choice != 'Q'));
return EXIT_SUCCESS;
}
void print_menu( )
{
cout << endl;
cout << "The following choices are available: " << endl;
cout << " R Activate one of the reset( ) functions" << endl;
cout << " 1 Add a new number to the 1st statistician s1" << endl;
cout << " 2 Add a new number to the 2nd statistician s2" << endl;
cout << " 3 Add a new number to the 3rd statistician s3" << endl;
cout << " T Print a table of values from the statisticians" << endl;
cout << " E Test whether s1 == s2" << endl;
cout << " + Set the third statistician s3 equal to s1 + s2" << endl;
cout << " * Set the third statistician s3 equal to x*s1" << endl;
cout << " Q Quit this test program" << endl;
}
char get_user_command( )
{
char command;
cout << "Enter choice: ";
cin >> command;
return command;
}
double get_number( )
{
double result;
cout << "Please enter the next real number for the sequence: ";
cin >> result;
cout << result << " has been read." << endl;
return result;
}
void print_values(const statistician& s)
{
cout << setw(10) << s.length( );
cout << setw(10) << s.sum( );
if (s.length( ) != 0)
{
cout << setw(10) << s.minimum( );
cout << setw(10) << s.mean( );
cout << setw(10) << s.maximum( );
}
else
cout << " none none none";
cout << endl;
}
//test.h
#ifndef STATS_H
#define STATS_H
#include <iostream>
namespace main_2C
{
class statistician
{
public:
statistician( );
void next(double r);
void reset( );
int length( ) const;
double sum( ) const;
double mean( ) const;
double minimum( ) const;
double maximum( ) const;
friend statistician operator +
(const statistician& s1, const statistician& s2);
friend statistician operator *
(double scale, const statistician& s);
private:
int count;
double total;sequence
double tinyest;
double largest;
};
bool operator ==(const statistician& s1, const statistician& s2);
}
#endif
没自己看要求,麻烦各位大大再帮我看一下...小弟在送10分
例子:
statistician s;
s.next(1.1);
s.next(2.8);
s.next(-0.9);
cout << s.mean( ) << endl;
教授要求:
# A default constructor, which merely does any initialization needed for the statistician to start its work
# The next and mean functions, described above
# A constant member function called length, which returns the count of how many numbers have been given to the statistician
# Two constant member functions called minimum and maximum, which return the smallest and largest numbers that have been given to the statistician. (By the way, these two functions and the mean function all have a precondition that requires length( ) > 0. You cannot use these three member functions unless the statistician has been given at least one number!)
# A constant member function called sum, which returns the sum of all the numbers that have been given to the statistician. This function does NOT have a precondition. It may be called even if the statistician has NO numbers (in which case it should return 0).
# An overloaded operator == which tests to see whether two statisticians are "equal". The prototype is:
int operator ==(const statistician& s, const statistician& t);
In order for two statisticians to be equal, they must have the same length (i.e., they have been given the same number of numbers). Also, if their length is greater than zero, they must also have the same mean, the same minimum, the same maximum, and the same sum. For example: Suppose that a statistician s has been given four numbers 1, 2, 3, 4. A second statistician t has been given four numbers 1, 1.5, 3.5, 4. Then the test (s==t) must return true since both s and t have equal values for all the member functions, as shown here:
1. s.length( ) and t.length( ) are both 4
2. s.mean( ) and t.mean( ) are both 2.5
3. s.sum( ) and t.sum( ) are both 10.0
4. s.minimum( ) and t.minimum are both 1
5. s.maximum( ) and t.maximum are both 4
# An overloaded + operator which has two statisticians as arguments, and returns a third statistician, as shown in this prototype:
statistician operator +(const statistician& s, const statistician& t);
# An overloaded * operator which allows you to "multiply" a double number times a statistician. Here is the prototype:
statistician operator *(double scale, const statistician& s);
This is not a member function. The result of a multiplication such as 2*s is a new statistician that looks as if it had been given all the numbers of s, multiplied by the constant 2. Examples: Suppose that s is a statistician that has been given 1, 2, 3, and u is another statistician. Then the assignment statement u=2*s will result in u behaving as if it had been given the numbers 2, 4, 6. As another example, the assignment statement u=-3*s will result in u behaving as if it had been given the numbers -3, -6, -9. Notice that neither + nor == are member functions. (See Section 2.5 in your textbook and the notes in lecture 3). The result of s+t is a new statistician that looks as if it had been given all the numbers of the sequence for s, followed by all the numbers of the sequence for t. For example: Suppose that we have three statisticians s, t, and u. The statistician s has been given the numbers 1, 2, 3; the statistician t has been given the numbers 4, 5. Then the assignment statement u=s+t will result in u behaving as if it had been given the five numbers 1, 2, 3, 4, 5.
展开全部
//stats.h
#ifndef STATS_H
#define STATS_H
#include <iostream>
namespace main_2C
{
class statistician
{
public:
statistician( );
void next(double r);
void reset( );
int length( ) const;
double sum( ) const;
double mean( ) const;
double minimum( ) const;
double maximum( ) const;
friend statistician operator +(const statistician& s1, const statistician& s2);
friend statistician operator *(double scale, const statistician& s);
private:
int count; // 有多少个数字
double total; //总和
double tinyest; //最小值
double largest; //最大值
};
bool operator ==(const statistician& s1, const statistician& s2);
}
#endif
下边是CPP文件:
#include "stats.h"
namespace main_2C
{
statistician::statistician()
{
count = 0;
total = 0;
tinyest = 0;
largest = 0;
}
void statistician::next(double r)
{
count++;
total += r;
if (r < tinyest)
{
tinyest = r;
}
else if (r> largest)
{
largest = r;
}
}
void statistician::reset( )
{
count = 0;
total = 0;
tinyest = 0;
largest = 0;
}
int statistician::length( ) const
{
return count;
}
double statistician::sum( ) const
{
return total;
}
double statistician::mean( ) const
{
if(count > 0)
{
return total / count;
}
return 0;
}
double statistician::minimum( ) const
{
return tinyest;
}
double statistician::maximum( ) const
{
return largest;
}
statistician operator +(const statistician& s1, const statistician& s2)
{
statistician s3;
s3.count = s1.count + s2.count;
s3.total = s1.total + s3.total;
s3.largest = (s1.largest > s2.largest) ? s1.largest : s2.largest;
s3.tinyest = (s1.tinyest < s2.tinyest) ? s1.tinyest : s2.tinyest;
return s3;
}
statistician operator *(double scale, const statistician& s)
{
statistician s1;
s1.count = s.count;
s1.total = s.total * scale;
if (scale > 0)
{
s1.largest = s.largest * scale;
s1.tinyest = s.tinyest * scale;
}
else
{
s1.largest = s1.tinyest * scale;
s1.tinyest = s.largest * scale;
}
return s1;
}
bool operator ==(const statistician& s1, const statistician& s2)
{
return (s1.length() == s2.length() && s1.maximum() == s2.maximum() &&
s1.minimum() == s2.minimum() && s1.sum() == s2.sum() &&
s1.mean() == s2.mean());
}
}
改的比较急,没有测试,不过编译通过了,大体应该没什么问题了。
祝你好运。
#ifndef STATS_H
#define STATS_H
#include <iostream>
namespace main_2C
{
class statistician
{
public:
statistician( );
void next(double r);
void reset( );
int length( ) const;
double sum( ) const;
double mean( ) const;
double minimum( ) const;
double maximum( ) const;
friend statistician operator +(const statistician& s1, const statistician& s2);
friend statistician operator *(double scale, const statistician& s);
private:
int count; // 有多少个数字
double total; //总和
double tinyest; //最小值
double largest; //最大值
};
bool operator ==(const statistician& s1, const statistician& s2);
}
#endif
下边是CPP文件:
#include "stats.h"
namespace main_2C
{
statistician::statistician()
{
count = 0;
total = 0;
tinyest = 0;
largest = 0;
}
void statistician::next(double r)
{
count++;
total += r;
if (r < tinyest)
{
tinyest = r;
}
else if (r> largest)
{
largest = r;
}
}
void statistician::reset( )
{
count = 0;
total = 0;
tinyest = 0;
largest = 0;
}
int statistician::length( ) const
{
return count;
}
double statistician::sum( ) const
{
return total;
}
double statistician::mean( ) const
{
if(count > 0)
{
return total / count;
}
return 0;
}
double statistician::minimum( ) const
{
return tinyest;
}
double statistician::maximum( ) const
{
return largest;
}
statistician operator +(const statistician& s1, const statistician& s2)
{
statistician s3;
s3.count = s1.count + s2.count;
s3.total = s1.total + s3.total;
s3.largest = (s1.largest > s2.largest) ? s1.largest : s2.largest;
s3.tinyest = (s1.tinyest < s2.tinyest) ? s1.tinyest : s2.tinyest;
return s3;
}
statistician operator *(double scale, const statistician& s)
{
statistician s1;
s1.count = s.count;
s1.total = s.total * scale;
if (scale > 0)
{
s1.largest = s.largest * scale;
s1.tinyest = s.tinyest * scale;
}
else
{
s1.largest = s1.tinyest * scale;
s1.tinyest = s.largest * scale;
}
return s1;
}
bool operator ==(const statistician& s1, const statistician& s2)
{
return (s1.length() == s2.length() && s1.maximum() == s2.maximum() &&
s1.minimum() == s2.minimum() && s1.sum() == s2.sum() &&
s1.mean() == s2.mean());
}
}
改的比较急,没有测试,不过编译通过了,大体应该没什么问题了。
祝你好运。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
//stats.h
#ifndef STATS_H
#define STATS_H
#define N 100
namespace main_2C
{
class statistician
{
public:
statistician();
void next(double r);
int length( ) const;
double sum( ) const;
double mean( ) const;
double minimum( ) const;
double maximum( ) const;
private:
int length_;
double s[N];
};
}
#endif //STATS_H
//stats.cpp
#include "stats.h"
#include <iostream>
#include <cstdlib>
using namespace std;
using main_2C::statistician;
statistician::statistician()
{
length_ = 0;
}
void statistician::next(double r)
{
if(length_>N-1)
return;
s[length_] = r;
length_++;
}
int statistician::length( ) const
{
return length_;
}
double statistician::sum( ) const
{
double total = 0;
for(int i=0;i<length_;i++)
total += s[i];
return total;
}
double statistician::mean( ) const
{
return (this->sum()/length_);
}
double statistician::minimum( ) const
{
double min=s[0];
for(int i=0;i<length_;i++)
if(min > s[i])
min = s[i];
return min;
}
double statistician::maximum( ) const
{
double max=s[0];
for(int i=0;i<length_;i++)
if(max < s[i])
max = s[i];
return max;
}
void main()
{
statistician s;
s.next(1.1);
s.next(2.8);
s.next(-0.9);
cout << s.mean()<<'\n'<<s.length()<<'\n'<<s.sum()<<'\n'<<s.minimum()<<'\n'<<s.maximum()<<endl;
system("PAUSE");
}
#ifndef STATS_H
#define STATS_H
#define N 100
namespace main_2C
{
class statistician
{
public:
statistician();
void next(double r);
int length( ) const;
double sum( ) const;
double mean( ) const;
double minimum( ) const;
double maximum( ) const;
private:
int length_;
double s[N];
};
}
#endif //STATS_H
//stats.cpp
#include "stats.h"
#include <iostream>
#include <cstdlib>
using namespace std;
using main_2C::statistician;
statistician::statistician()
{
length_ = 0;
}
void statistician::next(double r)
{
if(length_>N-1)
return;
s[length_] = r;
length_++;
}
int statistician::length( ) const
{
return length_;
}
double statistician::sum( ) const
{
double total = 0;
for(int i=0;i<length_;i++)
total += s[i];
return total;
}
double statistician::mean( ) const
{
return (this->sum()/length_);
}
double statistician::minimum( ) const
{
double min=s[0];
for(int i=0;i<length_;i++)
if(min > s[i])
min = s[i];
return min;
}
double statistician::maximum( ) const
{
double max=s[0];
for(int i=0;i<length_;i++)
if(max < s[i])
max = s[i];
return max;
}
void main()
{
statistician s;
s.next(1.1);
s.next(2.8);
s.next(-0.9);
cout << s.mean()<<'\n'<<s.length()<<'\n'<<s.sum()<<'\n'<<s.minimum()<<'\n'<<s.maximum()<<endl;
system("PAUSE");
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询