日记网 加入收藏  -  设为首页
您的位置:日记网 > 教育知识 > 正文
夹角(a,b)=(b,a)吗
夹角(a,b)=(b,a)吗
提示:

夹角(a,b)=(b,a)吗

亲亲,您好,不是。夹角(a,b)和夹角(b,a)是不同的两个夹角,它们的角度值也不相同。【摘要】 夹角(a,b)=(b,a)吗【提问】 亲亲,您好,不是。夹角(a,b)和夹角(b,a)是不同的两个夹角,它们的角度值也不相同。【回答】 【提问】 那请问第二题是选d吗【提问】 好的【提问】 亲亲,这题选的是B【回答】 向量a与向量b的夹角是写成(a,b)吗【提问】 亲亲,是的【回答】 然后(b,a)是向量b与向量a的夹角吗【提问】 亲亲,是的,但是向量a与向量b的夹角不一定就是向量b与向量a的夹角【回答】 那如果题目问向量a与向量b的夹角我求的是(a,b)吗【提问】 亲亲,对的【回答】 向量a与向量b的夹角就是(a,b)【回答】

求这题C++的答案
提示:

求这题C++的答案

#include#includeclass Point{ double x, y;public: Point(double x, double y) { this->x = x; this->y = y; } void print() { printf("(%f,%f)\n", x, y); } friend double distance(Point, Point); friend double area(Point, Point, Point);};double distance(Point a, Point b){ return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));}double area(Point a, Point b, Point c){ double s1 = distance(a, b); double s2 = distance(a, c); double s3 = distance(b, c); double p = (s1 + s2 + s3) / 2; return sqrt(p*(p - s1)*(p - s2)*(p - s3));}int main(){ Point a(5, 10), b(1, 67), c(50, -25); printf("三角形的面积为:%.3f\n",area(a,b,c)); return 0;}

急!请C++高手进来帮小弟看一下作业后,感谢!
提示:

急!请C++高手进来帮小弟看一下作业后,感谢!

//stattest.cpp
#include
#include
#include
#include
#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

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.