C++问题
c++ 求百分比题目:
牛牛最近学习了C++入门课程,这门课程的总成绩计算方法是:
总成绩=作业成绩 × 20% + 小测成绩 × 30% + 期末考试成绩 × 50%
牛牛想知道,这门课程自己最终能得到多少分。
来源oj:1565
这个题目很简单,你改成普通求助帖,会有很多人来回答你(不包括我,因为我只会C,不会C++),但是用悬赏求助,就不一定了 #include <iostream>
using namespace std;
class result
{
public:
result(float a, float b, float c) :homework(a), text(b), terminal(c)
{
sum = homework * 0.2 + text * 0.3 + terminal * 0.5;
}
float sum;
private:
float homework;
float text;
float terminal;
};
int main()
{
float a, b, c;
cout << "homework:";
cin >> a;
cout << "text:";
cin >> b;
cout << "terminal:";
cin >> c;
result re(a,b,c);
cout << re.sum << endl;
system("pause");
return 0;
} #include <iostream>
using namespace std;
class result
{
public:
result(float a, float b, float c) :homework(a), text(b), terminal(c)
{
sum = homework * 0.2 + text * 0.3 + terminal * 0.5;
}
float sum;
private:
float homework;
float text;
float terminal;
};
int main()
{
float a, b, c;
cout << "homework:";
cin >> a;
cout << "text:";
cin >> b;
cout << "terminal:";
cin >> c;
result re(a,b,c);
cout << re.sum << endl;
system("pause");
return 0;
} 风过无痕1989 发表于 2020-12-1 22:50
这个题目很简单,你改成普通求助帖,会有很多人来回答你(不包括我,因为我只会C,不会C++),但是用悬赏求 ...
谢谢!
页:
[1]