#21927: c++參考 別抄 我很爛

#### minecraftisgood (葉劭成好帥)

School : 臺北市立建國高級中學
ID : 103375
2022-09-13 15:39:55
a866. 6. Product Review Site -- | From: [203.72.178.1] | Post Date : 2020-07-31 14:47

#include <iostream>

#include<iomanip>

using namespace std;

int main()

{

double a,sum=0,n1(0),n2(0),n3(0),n4(0),n5(0);

while(cin>>a){

if(a==0) {

double j=n5,k=n4,l=n3,m=n2,s=n1;

double q=(j*5+k*4+l*3+m*2+s*1)/(j+k+l+m+s);

if(n5<10){

cout<<"5 ( "<<n5<<") |";

while(n5>0){cout<<"="; n5--;}

cout<<endl;

}

if(n5>=10){

cout<<"5 ("<<n5<<") |";

while(n5>0){cout<<"="; n5--;}

cout<<endl;

}

if(n4<10){

cout<<"4 ( "<<n4<<") |";

while(n4>0){cout<<"="; n4--;}

cout<<endl;

}

if(n4>=10){

cout<<"4 ("<<n4<<") |";

while(n4>0){cout<<"="; n4--;}

cout<<endl;

}

if(n3<10){

cout<<"3 ( "<<n3<<") |";

while(n3>0){cout<<"="; n3--;}

cout<<endl;

}

if(n3>=10){

cout<<"3 ("<<n3<<") |";

while(n3>0){cout<<"="; n3--;}

cout<<endl;

}

if(n2<10){

cout<<"2 ( "<<n2<<") |";

while(n2>0){cout<<"="; n2--;}

cout<<endl;

}

if(n2>=10){

cout<<"2 ("<<n2<<") |";

while(n2>0){cout<<"="; n2--;}

cout<<endl;

}

if(n1<10){

cout<<"1 ( "<<n1<<") |";

while(n1>0){cout<<"="; n1--;}

cout<<endl;

}

if(n1>=10){

cout<<"1 ("<<n1<<") |";

while(n1>0){cout<<"="; n1--;}

cout<<endl;

}

cout<<"Average rating: "<<fixed<<setprecision(4)<<q<<endl;

}

if(a==1) {n1++; sum+=a;}

if(a==2) {n2++; sum+=a;}

if(a==3) {n3++; sum+=a;}

if(a==4) {n4++; sum+=a;}

if(a==5) {n5++; sum+=a;}

}

}

ZeroJudge Forum