C++ 程序 跳过 输入语句
#include<iostream>usingnamespacestd;classdive{public:voidgetdata();boolcheck();voidca...
#include<iostream>
using namespace std;
class dive
{
public:
void getdata();
bool check();
void calculate();
void output();
private:
double judgmentscore[7];
int degree=0;
double totalscore;
};
int main()
{
dive lei;
do{
lei.getdata();
} while (!(lei.check()));
lei.calculate();
lei.output();
system("pause");
return 0;
}
void dive::getdata()
{
cout << "Please enter seven scores(0~10) by judge:" << endl;
for (int inset = 0; inset < 7; inset++)
{
cin >> judgmentscore[inset];
}
cout << "Please enter the degree(1.2~3.8) of difficulty:";
cin >> degree;
return;
}
bool dive::check()
{
bool judge;
for (int inset = 0; inset < 7; inset++)
{
if (judgmentscore[inset]<0 || judgmentscore[inset]>10)
judge = false;
}
if (degree<1.2 || degree>3.8)
judge = false;
return judge;
}
void dive::calculate()
{
int min, max;
double sum = 0;
for (int inset = 1; inset < 7; inset++)
{
if (judgmentscore[inset]>judgmentscore[inset - 1])
max = inset;
if (judgmentscore[inset] < judgmentscore[inset - 1])
min = inset;
}
judgmentscore[max] = judgmentscore[min] = 0;
for (int inset = 0; inset < 7; inset++)
sum += judgmentscore[inset];
totalscore = 0.6*degree*sum;
return;
}
void dive::output()
{
cout << endl << "Total score:" << totalscore << endl;
return;
} 展开
using namespace std;
class dive
{
public:
void getdata();
bool check();
void calculate();
void output();
private:
double judgmentscore[7];
int degree=0;
double totalscore;
};
int main()
{
dive lei;
do{
lei.getdata();
} while (!(lei.check()));
lei.calculate();
lei.output();
system("pause");
return 0;
}
void dive::getdata()
{
cout << "Please enter seven scores(0~10) by judge:" << endl;
for (int inset = 0; inset < 7; inset++)
{
cin >> judgmentscore[inset];
}
cout << "Please enter the degree(1.2~3.8) of difficulty:";
cin >> degree;
return;
}
bool dive::check()
{
bool judge;
for (int inset = 0; inset < 7; inset++)
{
if (judgmentscore[inset]<0 || judgmentscore[inset]>10)
judge = false;
}
if (degree<1.2 || degree>3.8)
judge = false;
return judge;
}
void dive::calculate()
{
int min, max;
double sum = 0;
for (int inset = 1; inset < 7; inset++)
{
if (judgmentscore[inset]>judgmentscore[inset - 1])
max = inset;
if (judgmentscore[inset] < judgmentscore[inset - 1])
min = inset;
}
judgmentscore[max] = judgmentscore[min] = 0;
for (int inset = 0; inset < 7; inset++)
sum += judgmentscore[inset];
totalscore = 0.6*degree*sum;
return;
}
void dive::output()
{
cout << endl << "Total score:" << totalscore << endl;
return;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询