【发布时间】:2020-06-14 20:04:57
【问题描述】:
您好,我刚开始学习C++,我有一个提示程序:
它类似于要求用户一次输入一个分配的输入,一旦他们没有更多输入,程序必须显示
"Stop"每个分数(布尔型)一次必须询问用户是否有更多分数要输入
它还必须获得平均值并将其置于 100 的刻度上并输出相关的分数,刻度为:
A = 100-93、A- = 92-90、B+ = 89-87等
以下是我目前所拥有的(如果我可以更好地为编译器格式化,请告诉我,我更喜欢在记事本中输入)
#include <iostream>
using namespace std;
int main() {
cout << "Welcome to the Homework Point Sum Progam!"
endl;
cout << "How many assignments did you complete?:";
endl;
int assignments;
int scores;
int total = 0;
int average = scores / assignents;
cin >> assignments;
// this next part I'm trying to find out how to set up the input for the assignments and have them line up as "assignment one, assignment two, etc."
if (assignment > 0) {
for (int i = 1; i < assignment; i++) {
else
// I would like to know if this is a valid input and formatting of "else" as well as if my placement of it is valid
cout << "Enter Assignment Score" << i << endl;
cin >> scores
total += scores
}
}
if (average < 33)
total += scores
cout << "Fail" << endl:
return 0;
}
【问题讨论】:
-
是的,您可以更好地格式化它,但这是任何现代 IDE 或编辑器都可以自动完成的事情。但我担心你的问题离题了,因为格式总是基于意见的。 (这是您的实际问题吗?)代码审查也是题外话,因为有一个专门的论坛:codereview.stackexchange.com
-
感谢您的澄清
标签: c++ algorithm operators feed